If the puzzle is necessary to proceed, then its railroading yes.
Even puzzles and ridles can have several solutions.
Putting mandatory "puzzles" on players, like having to guess how they can get out of the current situation, definitly is railroading.
As long as players can just skip puzzles its fine. Especially since its gard to make good puzzles, and they are rarely as clever as the people who create them think.
In some sense riddles and puzzles make not much sense in D&D, since you are roleplaying characters, so they would need to solve the puzzles, so it should be just a skill check / skill challenge.
In a way they are also just a relic of the past coming from a time where people did read the hobbit and thought these riddles there where clever, and when it was in generally rare to find (good) puzzles/riddles, so seing a homemade riddle was a fun change.
Today, however, where its so easy to find good versions of any kind of puzzle it makes not much sense if a hobby designer tries to create a puzzle and add it in an RPG. If people want puzzles they can buy exit games or other professional puzzles with good ratings.