Is there any rule that prohibits two teams that advance from the same group playing against each other before the final?
In the world cup the group structure is such that there are 4 teams each in 8 groups. The top two teams from each group advance.
The way that the bracket is structured after this advancement is such that it is impossible for two teams in the same group to play each other any earlier than the final.
To do this they structure the bracket so that the top team from one group plays the second team from another group and teams in the same bracket are on opposite sides.
for instance, here is the 2014 full tournament bracket. Using Group A as an example, the winner (Brazil) played the second place team from group B (Chile), and the second place team in group A (Mexico) played the first place team from group B (Netherlands).
This sets up a scenario where if both teams advance, they then play an opponent from groups C or D, and then an opponent from groups E,F, G or H to play for the final against an opponent from any of the other groups (including, possibly, their own).
For the 2014 world cup this was documented in this document, specifically on page 52-53, section 42-45. The document lists the matchups for each round providing letter or number codes to each and then using those in the subsequent section to describe the matchups. It's hard to quote here, but suffice to say the laws there describe the bracket listed above.
In a more general sense, FIFA's laws of the game is silent on how to organize a tournament, so it is up to each tournament how to schedule elimination rounds, however, in a round robin scenario with the top two advancing, if there are an even number of groups (especially when it's a power of 2), it is generally not hard to design the tournament such that teams in the same group do not play.
It's worth noting (as was pointed out in the comments), that this is something unique to the era of a 32 team field. Prior to this era, teams from the same group could play each other prior to the finals as several 3rd place teams would be included in the final 16.
The sequence of games is decided by the specific tournament rules. For example, La Copa Libertadores (South American Champions) starts similar to the World Cup: 32 teams in 8 groups of 4, the top teams of each group advance.
But them the group leaders are ordered by number of points and other criteria from 1 to 8, number 1 is the best team; group runner-ups are also ordered from 1 to 8. Then the best leader (number 1) plays against the worst runner-up (number 8); leader #2 x runner-up #7; etc...). By this arrangement, it is possible that two teams of the same group play again in the round of 16.
In the Wikipedia is easier to see how it works.
It depends on the competition. As the answers above have said, the World Cup has made it impossible for it to happen. However, if you take a look at the UEFA Champions League, the only round in which you can't have two teams from the same group play each other is in the round of 16. From the quarterfinals on, any two teams can be drawn against each other, including those who played together in the group stage.