Other way around, actually: he started out making constructed languages for fun, realized that doing that properly required inventing the cultural and historical context in which it developed, and then, later, started writing fiction set in that world.
Both.
Tolkien constructed an actual language for use in his works, and the gibberish you see on the keyboard is that language.
Other way around, actually: he started out making constructed languages for fun, realized that doing that properly required inventing the cultural and historical context in which it developed, and then, later, started writing fiction set in that world.