What the heck did you do?
First- That is not your magnet, it is your speed sensor. It might also be referred to a Tach sensor. The magnet is going to be a little disc mounted on your motor shaft. I don’t see any bits of it amongst the bits shown in your pic. Depending on what caused the above expansion of parts, you should also check on your magnet too.
Do you know what motor you are running?
Try doing a search with these two bits of information and look for pics of what you have.
It’s a very common part. You can find them via Amazon, Ebay, golf cart supply, etc.
There are really only two kinds, Flat and top hat. You have the top hat. Just make sure you get the proper plug which would be Deutch 3 pin.