Law 10 Method of Scoring
For simple explanantion, when the ball crosses the goal line completely between the goalpost and crossbar it is a score, unless there was a foul or law infringement that negates the goal. It does not matter which team touched the ball last.
Note: A direct free kick does not count as a scored goal if kicked directly into one's own goal. It will restart with a corner kick. This situation could occur if a player intends to kick the ball back to the keeper or another player who then misses the ball and it subsequently enters the goal.