Hub and Switch both are networking devices. But there is some major difference in the working of a hub or a switch.
If we talk about the hub, it is cheap and simple networking device. When a computer sends a data through a hub it actually replicates the data to all of its ports.
In the image above there is four computer in a network A, B, C and D. When A wants to send data to B through a hub, the data actually also transferred to C and D also. Hub is not an intelligent device and it does not know where to send the data.
Hub just replicates the data to all of the available ports including the receiver. So, the receiver, as well as other computers in the network, get the data. This can create a security issue or congest the network with unnecessary traffic. As a result, it is also a loss of bandwidth.
Also See: What is NFC
To get rid of these [roblems, Network engineers make switches. A switch is an intelligent device and only send the data to computers, who actually need it.
Switch identify a computer in the network using their MAC addresses. And MAC address is always unique in nature.