Shock, Corrosive, Incendiary and Explosive are the four gun elements.
Shock penetrates and knocks out shields, and may cause an electrocution DoT (Damage Over Time). Shock is weaker than other attacks against enemies without shields.
Corrosive does more damage against armored targets, and may cause an acid DoT, which increases all damage inflicted while the enemy is being corroded.
Incendiary does more damage against flesh and may cause a burning DoT.
Explosive works well all around but does not have a chance to cause DoT. Instead it causes all damage outright and has a chance to do splash damage.
Any enemy which uses an elemental attack is resilient to that particular attack. Therefore, if you see a spiderant who attacks with corrosive, don't shoot at it with corrosive as it will do less damage than normal.