There are many causes of knee pain, which I will not go into because they are very technical and somewhat boring to talk about. But here are some things to watch out for.
1. Twisting your knee. This can be even more risky if you twist it quickly (sports).
2. Wearing unsupportive shoes. You need shoes with arch support! This is especially true when you will be walking a lot. Do not go cheap on shoes because your body will suffer for it.
3. Not wearing orthotics. Not everyone needs orthotics, but those who do should wear them all the time. If you have one or more of these, you may need orthotics: flat feet, high arches, knock-knees, bow-legged, pigeon-toes, scoliosis (this list is not comprehensive).
4. Single knee trauma (car accident, fall, sports injury, etc). High risk sports are soccer, tennis, football, etc.
5. Thigh muscle weakness. Here is a simple exercise to get started with strengthening: straighten your leg in front of you (heel of foot can be on the floor). Lock your knee by squeezing/contracting your thigh muscles for 5-10 seconds. Repeat at least 10x.
To be continued!