2 things:
1) When a team passes it around the midfield, they're trying to create space which will lead to a meaningful attack. They could shoot from midfield anytime, but most likely the shot will be wide, high or blocked by a defender.
2) A historical understanding of the game is needed. Italy have always emphasized defence, and Costa Rica as an underdog were playing a defensive strategy. They caught Italy offside many times, and the strategy worked because they were able to take one of the few chances they created and won the game.
HTH
