Hackers are people who attack computers and networks for a variety of reasons. Reasons could be to get money, information, destroy stuff or just learn about the network.
Hackers have been classified in three groups. Black hat, gray hat and white hat. The current terminology is moving away from these terms to a generalist one of anyone who does stuff to computers and networks being called threat agents, whether they are good motives or bad motives. The terms come from the hats worn by the cowboys in old western movies.
Black hat hackers are what many people think of as hackers today. They are the ones who attack trying to get money, information or to destroy stuff. They are the bad people. However, the term hacker used to be a good term for people who were trying to learn everything about computers and networks for good.
White hat hackers are hired to attack computers and networks by the people who own the computers and networks to find weaknesses or holes in these computers and networks security, so they can be fixed. These people often do a process now call penetration testing or pen testing to find those holes. Some networks and cloud services do not allow this to be done. The white hats are the good people.
Gray hat hackers fall in the middle ground. They are not working for an organization to find holes but are doing it independently and not to do damage but will report to organizations when they find these holes or weaknesses.