This is one of those complicated questions to answer.
The ideal game length, IMHO, is tied to content and pacing. If a game ends and I feel like half the script ended up getting lost at some point *CoughIndigoProphecyCough*, the game is too short. If a game ends about 5 hours after I stopped caring about it or after it ran out of plot, the game is too long.
However, different game types do tend to have different sustainable lengths. Sandbox games can go for a long time because the plot is usually only a small part of those and the rest is doing what you want. RPGs can go for 20-50 hours due to the amount of time it takes to build your character and explore the sidequests. Action games and shooters, however, rarely seem to sustain more then 10 hours of playtime. Adventure games also tend to be on the short side, because the speed at which you finish them depends a lot of how long it takes you to solve the puzzles.
And there's nothing wrong with that. I don't want to add 10 hours onto to Uncharted if it means 10 hours of padding(And Uncharted 3 already pulled that crap with the Pirate ship, which was bad enough). A 40 hour adventure game would probably be murder to finish. A Skyrim type RPG where you run out of things to do and reach the ending in 10 hours would also be unacceptable.
For me(and surely others out there), gameplay length matters for another reason. If you have a job, a family, other hobbies, etc, or maybe you just have a massive steam/gog backlog, then you really don't have the time for every game to be 20 hours long. Sometimes a 4 hour game is just perfect. Something you can play through and enjoy over the weekend and move onto something else. I've actually been playing a lot of shorter games lately because that's more games I can scratch off my backlog list and make it feel more manageable. Then every so often I'll play a longer one, like a final fantasy game.