To expand on this, in linguistics, when you notice a similarity between two words, there are three main possibilities.
- Common ancestry. The English word "house" and the German word "Haus" are obviously similar, and this is because they both descend from Proto-West-Germanic, with the source word being something like hūs around 1700 years ago or so.
- Borrowing. The English word "chef" is a direct loan from French "chef". It's pretty common for the borrowed word to specialize its meaning somewhat. French "chef" merely means "boss", while English "chef" specifically means "boss of a kitchen" (who's probably from France because no one wants to eat English cooking).
- Pure coincidence. This dog example is the classic one, but it really does happen, and not exactly infrequently. There are only so many sounds in human language, and across all languages, you're bound to get some random collisions. There is the special case where both words originate from a phenomenon like onomatopoeia or infant language ability (think mama, papa, etc).
The first two are fun because they're evidence of some kind of historical connection, which can sometimes stretch back further than the historical record. Sanskrit in India having a lot of similarities to Greek and Latin is the classical example there (and controversial if you're a Hindu nationalist). Coincidence can be disappointing when you think you've discovered some exciting historical connection, but the dangerous bias that has to be kept in mind is that generally, if you're looking for something, you will find it.