We are not explicitly told where Tom gets his ideas for what sort of things to pretend to be. We have to infer it for ourselves. The only real possibility is that Tom has read about pirates and Robin Hood in books. Remember, there were no movies or even radios back then, so the only place Tom is going to get ideas like this is from books.
There is one passage from Chapter 8 that gives evidence that this is where he got his ideas. While he is swordfighting with Joe Harper, they argue about who should win. Tom says
“Why, that ain't anything. I can't fall; that ain't the way it is in the book. The book says, ‘Then with one back-handed stroke he slew poor Guy of Guisborne.’ You're to turn around and let me hit you in the back.”
This shows us that Tom has read Robin Hood, at least, and has done so often enough to memorize some of it. Presumably, then, he gets his ideas from books.