Hi Melissa!
There are two parts to understand. The first is related to computer science and the mathematics of information, and the second part actually has to do with physics.
Computer science / math part:
The purpose of the magnetic strip (or tap mechanism) is to store information. This is typically just some kind of identification number: when you pay for something with a credit card by swiping or tapping it, the action needs to communicate the information from the card (the card number, expiration date, etc).
Now, it turns out that you can represent any number that you are familiar with, only using a series of 1’s and 0’s. This is known as “binary”. You probably don’t need the details of how binary works, but you should know that every number can be represented by a series of 1’s and 0’s. For example, the binary representation of 139 is 10001011.
This is important, because it means that all of the credit card information can be represented as 1’s and 0’s.
Physics part:
A magnet has a north pole and a south pole. Now imagine that you draw an arrow from the south pole to the north pole; the magnetic strip on a credit card is made of a series of magnets, which either point up (representing a 1) or point down (representing a 0). In this way, the series of magnets, lined up in the strip, carry the binary information using the up and down orientations of each magnetic component to represent the binary number. This holds all the credit card information!
Tap has a different physical mechanism, which is a little more complicated. It uses an “RFID” mechanism, which stands for “radio frequency identification”. The RFID chip first recieves a radio signal from the chip reader; the RFID chip uses this radio signal to power itself, translating the input energy into an output signal. The output signal is a radio signal, at a different frequency, which has the credit card information encoded.
I hope this helps a little. Feel free to ask more questions!
Best,
Sam