First of all, you need to know that there is an established sequence of therapeutic treatment to follow in the event of a sprain, called P.R.I.C.E. (Protection, Rest, Ice, Compression, Elevation): it's a protocol with 5 steps, and you don't need a medical degree to do it - you just need to remember a few simple things.
Maybe you were a bit distracted, you slipped and you've twisted your ankle? First of all, learn to identify the alarm bells when you sprain something. It's likely that your joint will start to swell, you may feel pain and an annoyingly warm sensation. You might not be able to walk very easily either if you've hurt one of your lower limbs, so the main thing is to avoid making things worse (Protection).
OK, so it's official - you've twisted something. Start by resting the joint by not putting any weight on it (Rest). To limit inflammation, the general rule is to immediately apply a cold pack (Ice), and keep doing it for a few days, for 20 minutes every two or three hours, for 24-36 hours.
Once the joint is fully at rest, you can wrap your ankle with a bandage that will help you keep it immobile and reduce possible swelling (Compression). To make sure to limit any bleeding, keep your limb elevated. How do you do that? As an example, keep your leg raised by putting it on a pile of cushions (Elevation).
If you've got a Grade 1 sprain, where the damage is relatively light, an effective bandage and a few days of rest will be all you need. Basically, you're lucky: you've got away lightly.
If you've hurt yourself more than that, and the sprain, maybe to the knee or the ankle, for example, is Grade 2, your doctor will be able to tell you exactly what to do.
If you've got a Grade 3 sprain, you'll find it hard to move. If that's the case, keep in mind that your injury will probably have to be looked at by an orthopedic expert.