I heard that some things (like getting an abortion or attacking the pope) have the penalty of latae sententiae excommunication. What is that?
It generally means 'automatic excommunication'. Most people conceive of excommunication as something that happens to people, rather than something they do to themselves. That form of excommunication indeed happens (it recently happened when the Pope excommunicated an Australian priest), but is relatively rare. You cannot expect the Pope or the church to look at all our lives and make sure nobody does something naughty. Thus, latae sententiae came to be, which means excommunication that does not need an 'act' excommunicating them. Literally, the term means 'done excommunication' or 'excommunication as it is', as opposed to excommunication that has to be pronounced. A significant difference is that excommunication latae sententiae happens from the moment of the act onwards (meaning that for instance certain ecclesiastical acts become invalid but sometimes licit) while excommunication ferende sententiae takes effect upon pronouncement, regardless of when the offence has been committed.
For reference, Canon 1314 describes the difference between the effect of latae sententiae and ferende sententiae. Also, to clarify, it is procuring an abortion (i.e. it includes the person carrying it out and many more) and any use of force against the Pontiff. Also note that latae sententiae is not so much a form of excommunication but rather a general criminal doctrine of Canon law, meaning it applies to other forms of punishment, for instance some acts attract a latae sententiae interdict (Canon 1370§). Other things that incur latae sententiae excommunication include: heresy/schism, as well as the offence generally known as 'profanation of the Host' (throwing away a consecrated Host or retaining it for a sacrilegious purpose), which is regarded as an offence against God directly.
Latae sententiae excommunication means that the person becomes automatically excommunicated as soon as the offence is committed.
From the Catholic Encyclopedia:
The same immediacy applies to any other penalty marked latae sententiae; the term is not limited to excommunication.