Why do I feel sharp pain in my knees sometimes?

Depends. Most knee complaints are due to a mechanical issue, particularly if there is no history of injury. These type of injuries can be successfully rehabilitated. If there is a history of injury, then there may be some structural damage to the internal structures of the knee such as a ligament or meniscus. Either way, you should get evaluated by a sports medicine specialist or an orthopedist.