In a nutshell, insufficient oxygen reaching the brain. Possible causes of that include:
bradycardia (slow heart rate) ;
tachycardia (rapid heart rate) ;
atrial fibrillation (irregular heart rate).
(With respect to the last of those causes, my friend was having a meal in a pub one day and suddenly went face down into his food. Like you, he seemed to make a quick recovery but a medical check showed that he needed a pacemaker fitted to combat his atrial fibrillation. He was a fit, and otherwise healthy, PE teacher, so it can happen to anyone).
Blackouts can also be a symptom of epilepsy (among other things)
Doctors don't always identify the cause of blackouts straight away
https://www.nice.org.uk/guidance/cg109/documents/serious-causes-behind-blackouts-underrecognised-warns-nice3
but it's still worth seeing your GP.