How could you make your knee stop swelling up randomly?

A more important? The more important question is why is it swelling randomly. Get the diagnosis right and the treatment usually becomes clear.
Reason for swelling? Once the reason for swelling is determined, treatment can help prevent further swelling. You should be seen by an orthoapedic surgeon perhaps.