1) In a band jamming context?
2) In a bedroom context?
3) For recording purpose?
Do provide more info with your setup, context etc, if not most can prolly give general answer which might lead you going round and round before finding solution
Anyway, the general cause of feedback usually is on
1) Volume level playing
2) Proximity of the path between sound input(geetar/instrument) and output(amp)
3) Gain/distortion level of playing
If taking into consideration of microscopic pickup/tubes in amp etc, there be more reasons involved.
Oh well, end of the day, in order to prevent, imho, the first thing to find out is on what causes it in the first place.
Through method of isolation, from cables to effects to geetar to amps etc. Slowly go through each item in your signal chain, find out the volume level of playing/gain level/proximity between sound input(geetar pickup) and output(amp) etc which resulted in feedback.
Once knowing that, perhaps there be a better idea of preventing it.