Coconut has a very peculiar features like no other fruit/vegetable.With features like a hard, dark out shell with a soft white inner shell makes it special.
Why do we break a coconut in the temple
The outer shell is considered to be a person's ego, anger and all the negative qualities that can be associated, whereas the inner layer as the pure and all the positive qualities. And hence by breaking a coconut, we assure in the name of god, that we will break through our negative qualities(ego) to get to a new pure person with all goodness.
Because its like a proof, when something is said and done in front of others we tend to follow it with more dedication. So when we break a coconut in front of god, we make a promise that we will leave our negative qualities behind and change to a better person.
We don't actually break coconut right in front of god?
This is the way the custom has evolved to what it is today. Many big temples, the temple personnel itself breaks the coconut for us, with one exception (of what i have known) is the Tirumala temple.Here the person himself breaks the coconut, right in front of god, may be some 100 - 200 meters away, but still it direction in which we stand and break coconut is facing the god.
And, why every time when we visit temples? Once done should be fine!
This is because, human brain has hormones which make us gradually forget what we have once said or done. So but repeating this task over and over again, we assure that we will follow the path and not get misguided.