What is referred to as a "muscle knot" is also known as a "trigger point" or "myofascial trigger point". They are medically controversial little things, because despite being talked about so much and all of the equipment and "specialists" (sorry, I'm definitely gonna have to leave that in quotes) out there that claim to be able to alleviate them, their exact causes or even nature are unknown.
One of the theories is that they are local, painful spots in fascia. The fascia is thin, very tough yet flexible tissue surrounding muscles. It provide compartments for the muscles that protect them, transmits tension and reduces friction. There's probably still quite a bit to learn about them. The idea that these tissues could somehow become "bunched up" or otherwise develop "knots" which could be resolved with massage or foam rolling is contested.
Another idea is that these trigger points are actually localized patches of muscle tissue that are retaining waste metabolites. If true, massage and foam rolling could work by helping disperse these metabolites and improve blood flow to drain them.
Some information about the definition of trigger points can be found here: https://en.wikipedia.org/wiki/Myofascial_trigger_point
For a thorough, very long but highly interesting read, I'd like to refer you to this article. Paul Ingraham has devoted enormous time to the study of pain, stays on top of the latest information and reworks his viewpoints and articles based on new evidence: https://www.painscience.com/tutorials/trigger-points.php
It would take some time to read through that, but it's a good investment of that time.
Even though the exact nature of muscle knots is not well understood, there are therapies that people report success with. One of the most popular ones is foam rolling, a form of self-myofascial release. The painful part of the muscle is placed on a foam roller, pressure applied (lots of it, usually using a good portion your the body weight) and the area and surrounding tissue are rolled on. A decent foam roller will last a long time (don't go with the cheaper ones, they'll break), it can be used at home or in the gym without assistance and it seems to help for a lot of people. There's still some study required about how to roll effectively and safely. For example, rolling your upper back is fine, but don't roll your lower back. Don't roll directly over joints, but rather over muscle and ligaments near them.
Personally, I've neither found foam rolling or stretching to seem to deliver noticeable benefit on a short term for me, which makes me a bit skeptical. Weight lifting, on the other hand, has provided immediately noticeable results (such as being able to lift more weight consistently with training progression) and seems to have made my body less susceptible to some muscle and joint pains I used to have. So I'd rather put my time into what actually works for me. Your mileage may vary. Of course, being 31, my opinion on this might be very different in 10 years or so.