A dialect is a version of a language. Some of the words might be the same as the main language, some are not.
In mainland UK, (most) people speak standard English all using the same words. However, people from London will say words in a slightly different way (same word, different sound) from people in Liverpool or Manchester, for example. They have a London/Liverpool/Manchester accent but they don't speak a dialect.
In Spain, most people speak Castilian (the Spanish that is generally recognised). However, in Barcelona, for example, they speak Catalan - a dialect. You can see similiarities with Castilian but the spelling is very different, many words are completely different from their Castilian equivalent.
In extreme cases, two people from the same country, but who speak different dialects, won't be able to understand each other.
Student or Learner