There is absolutely no way to know this for sure. It is a case of the age-old paradox: which came first, the chicken or the egg?
I will start with whether they can only say their name, since that is easier. It is not always the case, although it usually is. Meowth from Team Rocket is the only known example of a Pokemon that has actually taught itself to speak human (that I can think of). Many Psychic types, legendaries, and a few others, seem to be able to communicate via telepathy instead. I can recall Mewtwo, Lapras, Shaymin, Jirachi, and various other Pokemon "talking" in this way.
Now I will move onto how they were named. Logically it makes no sense for Pokemon to only be able to say what the humans named them, meaning that they were probably named after the sounds they made. This then raises the question of how Pokemon like Charizard or Onix, which really only roar, were named. But this is just a theory, because as I said at the start there is no way to know for sure.