Wow, that was fast! The most important thing is to keep yourself hydrated. Did you bring something like Dioralyte sachets with you? If not, can you get someone to go to the pharmacy for you? Last resort, make your own with half a teaspoon of salt and a couple of teaspoons of sugar. Gatorade and coconut water are good drink too. Drink only bottled water not tap water, but lots of it. Sip it if you are not feeling well, don’t guzzle it. Try to stay out of the heat while you get over this, as sweating will dehydrate you too.
WRT Imodium, only take it if you are crippled with diarrhoea, as it basically stops you ejecting the bad stuff from your system. Being sick and diarrhoea are the body’s way of getting rid of digestive bad stuff.
To prevent it happening again, make sure you wash your hands before eating every time you eat. Be obsessive about it. Use soap and water, or a little bottle of sanitiser gel if you are out and about. Only drink bottled water. Don’t have ice in your drinks. Use bottled water to brush your teeth. Avoid salads as they will have been washed in water, probably tap water. Be cautious around buffets, especially seafood buffets (however in Mexico the ceviche is generally good, as the fish is pickled in lime juice which usually kills off any bacteria.) Try to only stick to hot freshly cooked food - if it’s been sitting on a buffet for a long time it has probably had numerous opportunities to find various types of bacteria.
With any luck you are just experiencing a minor adjustment to your body’s normal equilibrium and you’ll be over it by tomorrow. My experience of Mexico (and most of the holiday resorts I’ve been to) is that the food is generally very good in restaurants where it is cooked fresh, but that all inclusive buffets are basically asking for it. If you are in an all inclusive, try to stick to food you know has been cooked just for you ie the a la carte rather than the buffet.