Why doesn't the avocado turn brown when it is kept with its seed?
This is actually only partly true: When you cut the avocado in half, only the part where the seed really sits stays green, while the surrounding cut area gets brown over time. 

Avocados turn brown because of an enzyme called polyphenol oxidase, which oxidizes the green contents of the avocado upon contact with oxygen. The seed blocks the access to oxygen, thats why it helps here (but only where it makes close contact). See this and this links.

There are two ways of preventing the browning of cut avocados (besides avoiding oxygen contact): Use either lemon juice, which inhibits the enzyme (by chelating the metal ion from its active center) or keep it cooled to slow down the procession rate of the enzyme (which will only work for some time).