I don't suppose "because they can" is an adequate answer. Goats use their horns for lots of things. To move objects like rocks so they can get at some food. For display and competition during mating season. For self defense. Goats have an instinct to ram thier rivals with thier horns. It impresses the girl goats, you see. So it's a pretty powerful instinct.
So why do they ram people? Well, think about it from the goat's point of view for a moment. Here's this weird animal that's on your territory. He's walking around like he owns the place. In a goats world there's only 2 things that do that. Either that human is a large, dangerous animal, or he's a wierd kind of goat and thinks he's better than you. Either way, you want him to go away. Now, being a goat, it's not like you can politely ask him to leave or threaten to shoot him. No, your only weapon is your horns, and by golly, your gonna use em. Wham!
Make sense?