All [ <bond,angle,dihedral,...>types ]
sections must come before the first [ molecule types ]
section, see Common errors when using GROMACS - GROMACS 2024.3 documentation.
The other errors you are getting before is because of the same error, i.e., the parameters of bonded interactions are not defined when you use them. Move bonded and non-bonded [ ...types ]
sections to a separate file and include that after the forcefield.itp
in your topology file.