This sounds like you probably have a paronychia, which is the medical terms for an infection in the soft tissue of the nail fold on the sides of the nail. As you have already anticipated, the most common causes of developing a paronychia include damage or trauma to the nail or nail fold, as well as from ingrown toe nails.
You should go see your primary care doctor
for help with this problem. They will be able to determine how bad the paronychia is, and what medical treatments might be needed.
Simple paronychia can sometimes be treated with simple home remedies, such as soaking the foot in warm water to draw out the infection and applying a topical antibiotic ointment. However, more complicated paronychia may actually contain a collection of pus that will need to be drained in order to heal. If the infection is very severe, you may also need to take an oral antibiotic medication in order to clear up the infection.
Your doctor will be able to help you decide which of these options is right for your case.
In the meantime, avoid picking at or manipulating the area, and wear loose fitting shoes so that pressure does not make the problem worse.