Following on from another similar thread that I vaguely remember...
I was taking the rear caliper off to bleed it, and this nut dropped on the floor. Can't see or think where it might have come from. Could have come from something else, but it seems unlikely.
Think it's M3 (will go check), black anodised, looks like a nylock, and has a groove worn in it, as if it's been holding a cable. Yup, def ME.

Rear of the bike in question

I'd guess maybe it fell from that bus that crashed on the moon?
From your workstand? It doesn't look like part of the brakes unless it is part of the levers?
Is the gear cable still attached to the mech?
I don't think I've ever come across nylock on any bike part, and that doesn't look like any nut you would see on a bike. Looks more like a nut from skateboard hardware or as mentioned above, off the stand.
Rc car wheel nuts?
Could be from a light mount. Some of them use nyloc nuts. I can't think of any standard component on that bike that would use one.
Have you checked the Crocs?
It may have just flicked up off the road, and lodged in your bike?
is it a nut off a reflector
Looks like a nyloc nut that is used for a rear light or reflector
Cheers for all the suggestions, some of them were even sensible 😮
It was neither an RC wheel nut, nor a tagnut 😃
I was checking of the ideas when I noticed the pedals... The same ones I took a few bent pins out of the other day... Mystery solved.
Are you a bodger ? I sometimes use old nuts to "space" up things like calipers, say if the screw I have to hand is too long (M3's pretty small, mind)