Since I don’t think this question has been answered yet:
An NFL team will have 45 “active players” on their roster for any given game. As you’ve seen, they only have 11 players on the field at a time…yet, nearly every active player gets in the game at some point.
Players nearly always specialize in playing either on offense or on defense; it’s extremely rare for a player to play on “both sides” of the ball – and, these days, when it’s done, it’s nearly always because a team is running out of uninjured players at a particular position, and has to have a player play at a different position. For instance, the New England Patriots, in the past few games, have been playing Julian Edelman, one of their reserve wide receivers (an offensive player) play on defense, as a defensive back, because they’ve suffered so many injuries among their defensive backs.
Teams will frequently change players from play to play, even if they aren’t changing from offense to defense (or vice-versa). Over the past three or four decades, the game has gotten very specialized, and teams will run different “packages” of players for different kinds of plays. For example, if an offense needs to get a lot of yardage quickly, they will go into a “passing package”, which means they will put four or five wide receivers on the field at once (a “standard” offensive package would typically only have two wide receivers). In response, the defense will go to a “nickel package” or “dime package”, which means they’re putting more defensive backs on the field (the fast guys who are good at staying with the wide receivers), as well as possibly putting in players who specialize in pass rushing (i.e., chasing the quarterback).
In addition to offense and defense, there’s actually a third type of player group: special teams, which refers to any play in which the ball is actually kicked (field goals, extra points, punts, kickoffs). Most of the players who play on special teams are reserve players at offensive or defensive positions, but there are usually at least two players who only play on special teams: the kicker and the punter. (You might find it interesting to note that several NFL punters have come to the NFL from Australian Rules football.)