Flams are very simple rudiments. You “flam” by playing a primary stroke with a quieter, grace note on the opposite hand. The quieter grace note should hit slightly before the primary stroke.
When you’re jumping on a trampoline and someone else bounces at exactly the same time, both of you lose your bounce and collapse, right? Think of the two people as your two strokes. When flamming, the strokes should not hit at the same time. (That would be called a “double stop.”) On the other hand (pun intended?), be sure that you can hear the first note, but don’t make it too disconnected from the beat.
If I dropped a watermelon from the top of a building, and my friend dropped one from the second floor, obviously hers would hit the ground first. Keep your grace note low, and it will naturally hit the drum before the main stroke. When alternating from Right hand to Left hand, know that you’ll be going from an upstroke to an downstroke, or vice-versa. (In an upstroke your stick rebounds back up, and in a downstroke the stick freezes in playing position.)