In an E1 reaction, I understand that the base reacts with the hydrogen of the carbon which is next to the positive charged carbon of the cation (of an haloalkane), because this hydrogen is supposed to be acidic. Why is that? And again, in an E2 reaction, why is the hydrogen that is attacked by the base, acidic? I am not sure how the polarity of the halogen affects the situtation.
After the first step of the reäction (i.e., loss of the halogen), you have the carbocation. You could draw a resonance structure of this: push the electrons from the C–H bond into making a new C–C bond, leaving you with an alkene and a nearby proton (note the conservation of charge, moving the + from a carbon to the hydrogen). This is like the reverse of an addition of a hydrohalic acid to an alkene, whereïn you'd have the double bond attack a proton, then have the halogen attack the carbocation. Either way, you've drawn a very reasonable* resonance structure showing an alkene and H+. That H+ is pretty much the definition of a Brønsted acid, so that would be a hand-waving explanation of how to see this hydrogen as being particularly acidic.
For the E2 example, we can't use the same method because we can't show this resonance structure (well, we kind of can if you want to get into a really tedious discussion that would be highly debated). You'd probably want to use the argument about halogens being inductively electron withdrawing, which pulls electron density away from nearby bonds. This results in less electron density existing in the C–H bond, making the bond longer, and slightly increasing the positive charge on the hydrogen. Since Brønsted acid theory defines the acid as being H+, the more we can show a partial positive charge on the hydrogen, the more Brønsted-acidic we can argue it to be.
* Note that I mentioned drawing a "reasonable" resonance structure. That's important, because we could technically show a resonance structure of benzene as having a carbon with a negative charge and a hydrogen with a positive charge, but that wouldn't be an argument for that hydrogen being particularly acidic, as it's a horrible resonance structure to draw.
It certainly is more complicated than this, but I feel like this highlights some of the most important effects without oversimplifying to the point of making anything explicitly wrong or creating a bunch of exceptions.