If it's s subungual hematoma would I have hurt it in some way? Or would it be painful?
Possibly yes and no. "Runner's toe" is a term describing a common condition seen in runners caused by downward pressure. Runner's toe is often associated with malfitting shoes and insufficient space for the toes. This may not cause you pain but the slight repeated injuries over time can build up to cause blood build up. Or, of course, you may of injured it with a knock on the toe or something. Sometimes these can take months to develop. You may of injured your toe but simply forgot about it because it caused you no concern.
But like I said, I am no doctor. Only a professional can give you an accurate diagnosis so seek professional advice. But from the picture, that's what it looks like to me. There are other toe conditions that can cause discolouration like yours. But in any case, it certainly doesn't follow the usual appearance of a melanoma of the toe. Whatever it is, I don't think you should be worrying about it being a melanoma. Melanoma takes months sometimes years for it to develop - and when it does, it is usually a longitudinal black line. Even if it was a longitudinal black line, there are other benign conditions that can mimic a melanoma of the toe. Melanonychia for example. But these conditions, including melanoma are most commonly seen in darker skinned patients. Bob Marley famously died of Subungual melanoma.
I have been through this worry myself by the way. I saw a grey spot/patch on the palm of my hand - I automatically thought it was melanoma. I also bite my nails which sometimes causes blood blotches to appear at the nail bed which last for months. And because they last for months, I always have the slight worry about it being melanoma.
But after checking the statistics over and over again in times of worry, I find that the probability is extremely small for me. And the same applies to you.