According to Wikipedia, the term 4X comes from a 1993 preview of ”Master of Orion” in ”Computer Gaming World” by writer Alan Emerich. The term was originally a pun on the “XXX” used by adult cinema. The 4X-genre is considered to be a sub-genre of the strategy-genre, that has its roots in large scale board games. 4X-games most often come in the turn-based variety, but this is not a rule. It's just the most common way to make these kinds of games. The reason is that your standard 4X-game contains a lot of information that needs to be studied, digested and executed upon. And while you can do that in a real-time scenario, it is much easier to just remove the time-constraint an allow the player to take his or her time to make the appropriate decisions.
The X-es in “4X” stands for:
Broadly speaking, this explains the most common game-play-loop. While most games in the genre are a lot more complex than this, even the ones made back in 1993, the moniker has stuck and serves as an appropriate describer of the genre.
Now, that you know WHAT a 4X-game is. You might be wondering, but what does it look like? How does it play? To that I say: “Imagine Civilization, you've now imagined a 4X-game.” If you need a better answer:
Your standard 4X-game is a strategy game where you usually take the role of an administrator of an empire, a nation or a group, and you must take said group from humble beginnings to greatness. It is usually a long-form game where you gradually expand your territory, you gradually improve your settlements and you gradually improve your technology. It is meant to be an abstract simulation of the rise and fall of any given group/nation/civilization. Your role is to facilitate this, by taking settlements, building improvements and defending them from outward threats. They come in a lot of different shapes and forms. Some are like Master of Orion and Galactic Civilizations, that have you ruling over an intergalactic civilization. Some are like Civilization, that have you command a nation through the history of the world. Some are like Endless Legend and Warlock, that use the Civilization model, but apply it to a fantasy setting. There are no hard rules for WHAT a 4X-game can be, but most fall into the strategy game genre. As a small note, there are even space-simulator games that follow the 4X-rules-set and are considered such. This gives the creators a lot of freedom to shape and form their own idea of a world(or galaxy) and it also gives the player a lot of freedom to explore different types of governing bodies, ideals or just ways of making a very nice and efficient empire. Personally, I see most 4X-strategy-games as a puzzle, to create the biggest and most efficient empire that the game allows me to.
Lately, we've seen a rise of “narrative driven”-games. These are games where story is key and the story that is told is the selling point of the game. I find that a lot of these “narrative” games miss what the 4X-genre already have created. See, when you play a 4X game, you make the narrative. The world you shape with the ideals your choose become the narrative. These can be nice Utopian ideas of what humanity should be struggling towards. Or they can be dystopian tales of well functioning, but in the end horrifying, dictatorships. In my opinion, every 4X-game has a lot of stories to tell, but none of them are written, they are written by the player, when you play.