The cameras that Hawk-eye uses are not situated in the goalposts, but much further away around the stadium. There are 7 cameras for each goal IIRC.
If the camera is too close to the action, the ball will appear to be bigger from one angle than another. If you imagine taking a picture of a football from 1 foot away, and another shot with the ball 5 feet away, it will appear smaller.
The same logic applies to Hawk Eye - for it to recognise the ball and to determine if it is a goal, the ball needs to appear the same size, regardless of whether a shot was in the near post, or far post. If it was too close, the system would find it difficult to recognise the ball (as it's size/appearance changes). This is why they are around the stadium and not in the goal posts.
hope this helps