One problem is, “carpet” and “rug” have the same name in Chinese: ditan (地毯). These items are similar in that they are a piece of covering on a floor. However, there are some important differences that should make it clear.
A CARPET is usually big enough to cover 100% of a floor. You might hear the phrase “wall to wall carpeting” to describe a room or house. Also, a carpet is usually cut to the exact size and shape of the room, and is installed and attached to the floor so it cannot move around. Once you place it, it stays there usually until you want to throw it away and get a new carpet. Also, in the US at least, a carpet often does not have a pattern; it is just one color.
A RUG, in contrast, is usually smaller than carpet and covers only part of a floor. It is not attached so the floor, so you can easily move it to different parts of a room, or even different rooms. Rugs often have a pattern and are rectangular in shape, but some are round or oval.
A Mat is what is called dianzi (垫子) in Chinese. It is usually even smaller than a rug, maybe a little thicker, and is often placed right in front of a door or in a place where a person stand often and needs extra cushioning for their feet. (For example, I have a standing desk in my office, and it came with a cushioned floor mat so, if I stand for hours, my feet and legs will still feel comfortable.) There are different kinds of mats for different purposes. A welcome mat of doormat is in front of the front door; it serves to welcome guests and is a place to wipe off one’s feet. (Most Americans wear their shoes into homes.) An Exercise mat is foamy and even thicker. One can lie on it and exercise or stretch. A Place mat is different in that it goes on a table and is below the plate, silverware, and cup.