They were not held in with foam. They were held in with "rivnuts", or threaded rivets. Once you pull them out, you can't put them back, ever, unless you get new ones, and buy the rivnut tool.
To fix it, go to Lowes, or your nearest hardware store and ask for "well nuts". They are usually brass, and are surrounded in rubber. The metal part expands as the bolt is screwed in. The rubber part fills the hole and seals it. Get the size that fits snugly in the holes, and new bolts and washers too.
If you don't know what I mean, just ask one of the store employee's (find one that knows their shit) and I'm sure they can help you.