Kingdom Hearts X was the original web browser game that was only released in Japan. It tells the story of the events that led up to the Keyblade War.
Kingdom Hearts Unchained X was the first incarnation of the mobile phone game, and it is actually a SEQUEL disguised as a port of the original browser title. You see, after the Keyblade War, all the fallen Keyblade wielders and Dandelions got somehow put into the Unchained Realm, which is basically the Realm of Sleep from all we know about it, to relive all the events that led up to the Keyblade War, MINUS the actual battle itself. That way, all of their memories will be gradually erased and they will forget and be able to move on from the War. So, in Unchained X, you play as the same character from X, but reliving most of the events of X in a dream.
Kingdom Hearts Union X acts as the "second season," as Nomura puts it, of Unchained X. So, at this point, it is still unclear where the distinction between the Unchained Realm and the Data realm is drawn—it could even be that the Unchained realm actually is the data realm instead of the Realm of Sleep as everyone has taken it to understand (don't quote me on this, I'm not completely sure). But basically, Union X follows all of the events after the player and other Keyblade wielders have successfully had their memories of the War undone in Unchained X, and now follows the events afterward having to do with the new Union leaders, the mystery surrounding Strelitzia's murder (which was not introduced until Union X), and the inexplicable appearance of the Game Central Station linking to the data Daybreak Town.
It's ridiculously confusing, but here it is more simply:
Kingdom Hearts X – Keyblade War
Kingdom Hearts Unchained X – Sequel to X, revision of the War
Kingdom Hearts Union X – Sequel to Unchained X, mystery of the data Daybreak Town
The explanation of these connections is VERY poorly handled in the actual games, and is only made more confusing by the egregiously long waits we have to endure between relevant story updates. So, you're not alone in not knowing what the hell is going on with this saga. It really is the writers' fault for telling the story so badly.