According to this question about Tangled, Rapunzel couldn't get her hair back. Then why is she shown with long hair in Ralph Breaks the Internet?
Because all of the Tangled merchandise uses Rapunzel with long hair. So the Princesses are depicted with their common look and standard costume, the actual movie plots have no bearing on their appearance in Ralph Breaks the Internet.
In the Tangled TV series, Rapunzel gets her hair back:
Since the movie also contains a reference to Cassandra from the show, it would appear that the movie takes place including TV canon.
This reference, by the way, is a painting of an owl on the wall during the princesses scene that looks quite similar to Cassandra's owl from the TV series.
(Hat tip to Flicks and the City, at around 4:40.)
Also, of course, because she wouldn't be recognizable without her distinctive hair.