Maybe what you need is a rehabilitation program to increase muscle strength and improve proprioceptive function. Proprioception is the joint’s sense of its own position. Tiny receptors inside the joint send messages to the brain whenever even the slightest change in position or movement occurs.
But any damage to the joint (either a traumatic injury or degenerative changes with aging) can decrease the joint’s ability to receive and respond to proprioceptive messages. The result can be instability like you are describing.
There can be other factors contributing to an unstable knee. Muscle weakness, ligament ruptures, and cartilage tears are possibilities. It’s probably a good idea to see an orthopedic surgeon who can evaluate your knee specifically. If there’s nothing specifically wrong, then a program of strengthening exercises with an emphasis on proprioception might be just what you need.
You’ll want to include exercises to strengthen the quadriceps (muscle along the front of the thigh), the hamstrings (muscle along the back of the thigh), and even muscles around the hip and ankle. Studies show that exercising in the seated position (nonweight-bearing) helps improve motion, strength, and function. But exercises done in the standing position or seated with the feet in contact with some form of resistance (weight-bearing) is even better.
With weight-bearing exercises, you will strengthen and improve proprioception. Those two things combined together can help improve stability and function and even help prevent falls. If your doctor clears you medically and there’s no need for more aggressive treatment such as surgery, then seek out the services of a physical therapist and get started. The physical therapist can help you find the right type and amount of exercises for this problem.