It does affect some positions, but not all of them.
Goalkeepers need to be tall to maximise the chances of reaching a high ball. In fact, most of them are over 190cm. There are even some examples of really tall goalies like Thibaut Courtois who is 199cm.
Centre-Backs also need to be tall and physically strong because they need to head high balls, and body-check the opponent players. One of the best centre-back in the world, Virgil van Dijk, is 193cm.
Full-backs don't need to be tall (actually I rarely see tall full-backs), they need to have good stamina for 90 minutes and be very fast. For instance, Trent Alexander-Arnold is 175cm (not so tall).
Midfielders don't need to be tall, a regular height is ok. They just need good passes. Like Frenkie de Jong is 180cm, not so short and not so tall.
Two types of attackers need a different height. The first type is the "Target man" and the second type is just a regular attacker.
A target man stands in front and everyone feeds them the ball. Those people need to be tall and strong so they can head the ball, bump the defenders and maybe control the ball with their chest. Zlatan Ibrahimovic is a target man and has a height of 195cm.
A regular striker doesn't need to be tall (in fact, it's actually better to be short) because if they are tall and they dribble, defenders will pull them down since the latter are tall. Whereas if they were short and stocky it would be hard for defenders to pull them down because they're already taller than the strikers, so they would have to trip you or fall on you, which could get you a free-kick or a penalty. A short striker is Messi (170cm) or Maradona (165cm).