The closest two kings ever get is a knight’s move apart: a white king on e4 with a black king on d6 is an ordinary position that nobody blinks at. Line them up on a rank, a file or a diagonal, though, and there is always at least one empty square between them. Not out of politeness. It falls straight out of the rule for how a king moves.
Where the gap comes from
A king may not move to a square attacked by an enemy piece. A king attacks the eight squares around it. Put those two sentences side by side and the ring of squares around the black king is permanently closed to the white king, and the other way round, so the two of them can never end up touching. It is the same fact that makes a king unable to take a king.
Online you never learn this, because the board just refuses the move and you assume the software is being fussy about something. Put two kings on a real board and shove one at the other and the rule explains itself before you have finished the push.
The gap has a name
Two kings facing each other with exactly one square in between is called the opposition, and it exists only because they are not allowed any nearer. Whoever has to move first has to step aside, which is why in a king and pawn ending the entire result can hang on whose turn it is. There is a page on what the opposition is, and I would put it near the top of the list of things a club player should actually know.
Close kings are strong kings
The gap is not a safety cordon, and reading it that way costs beginners games. Look again at the diagram: the white king on e6 is taking d7, e7 and f7 away from his opposite number, three of the five squares a king on the back rank has, from what feels like a respectful distance. That is real work, and it is unpaid, because the enemy king can never punish him for it.
Every basic checkmate runs on the same arrangement. The rook or the queen gives the check; your king, parked two squares off, holds the flight squares. So push it forward. Once the queens are off, the king is a fighting piece rather than a liability, and the only piece on the board that can never be captured.
Nearly every pawn endgame puzzle is this one square, dressed up: two kings, a gap, and whoever has to move first.