Perhaps the people actually were singing while on set so as to look like they were singing, but movie song and dance numbers are practically always lip-synced; even if people sing on set the performance won't be recorded.
The reason for this is that films are assembled using pieces of many different takes. With spoken dialog, it's possible to piece together a soundtrack from a few different takes (which may or may not be the takes that appear on screen) and have it sound good. With musical numbers it's often harder and there's no way of knowing before editing whether it's going to work. Consequently, music is generally recorded and edited first, and then played back on set during filming.
BTW, West Side Story is somewhat curious: there, the actors recorded the songs and shot the film, and then other people redubbed the singing afterward. Personally I preferred Natalie Wood's singing (what I've heard of it) to Marni Nixon (her replacement). While she may not have been a great singer, her performance seemed to match her on-screen persona much better.