On the screen on my MacBook Air, there are some little square marks from the keyboard.
Are they permanent, or can I clean them off? How can I prevent this from happening in the first place?
If you are very lucky it is just dirt and can be wiped off but usually it is permanent and there isn't much way to avoid them. I have seen it happen even when a soft cloth is used to cover the keys when the lid is closed. In fact that may even make it worse as the cloth adds thickness to the sandwich and may make the contact between the high points of the screen and the keys firmer. The screen surface of an anti-glare display just isn't very hard - glossy glass is harder but can still be marked.
Using a quality micro fibre cloth with a 70% water/30% isopropyl alcohol solution is a good way to clean the marks off if they are not permanent. I have been using the cleaning solution provided by my optician for my glasses for years with no ill effects, and I love the iKlear blue microfibre cloths (for both glasses and displays). They call it "terry" as opposed to their "chamois" cloth.
The MacBook Air keyboard shouldn't be touching the screen when it's normally closed. This only happens when you've put the computer under pressure when it's closed. For example, maybe you put it in a backpack with heavy books surrounding it and putting pressure on it.
About whether they're permanent, it depends on how "etched" they are. If you try a moist, soft cloth and rub the screen gently for about a minute, and they don't come off, then unfortunately they most likely will not ever come off. If you're still under AppleCare, they might fix this for you.
You can prevent this from happening in the future by putting a very thin cloth between the keyboard and the screen when you sleep it. Also, try not to put pressure on the computer, then it won't happen in the first place.