A file = data.
A text file = data can be interpreted as characters (letters, numbers, symbols).
A "binary" data file = data can not always be interpreted as something printable on screen.
Text files are a bit hard to read ("parse") in programs. But they are easy to edit by users.
Reverse is true for binary files.
Also, you can store more data in a binary file than in a text file of same size.
.dat and .txt is just file extensions. It doesn't matter what file extension you use but there are some conventions. .txt is often used for files containing plain text that can be opened and viewed with a simple text editor. .dat is often used for all kinds of stuff to store data that is not just plain text.