Ultimately, temperature is just the average kinetic energy of particles bouncing around inside an object. But how we measure it really depends on what it is we are measuring.
For small, accessible objects at moderate temperatures (which includes objects like cars and people), we have lots of methods, and the most typical way is to use thermometers, which are actually just two different substances (such as glass and mercury) with known, different rates of expansion due to temperature, such that we can compare their relative sizes and read off the temperature. To measure the object, we simply put the thermometer on it and wait for the heat to be conducted until the two objects reach thermal equilibrium. Then, we read off the calibrated thermometer what the temperature is. (How did we calibrate it in the first place? By placing it in water which we then cooled and heated to its freezing and boiling points, which are by definition 0 C and 100 C respectively).
But obviously that won't do if we're talking about something which is very large, very hot, or very far away---such as the Sun, which is obviously all of those things. Then, a better method is to use spectroscopy, where we study the spectrum of light radiated by the object. This spectrum we can then compare to mathematical models we have from quantum mechanics of blackbody radiation, which is the radiation that all substances naturally emit simply due to the fact that they are warmer than absolute zero. This can give us a very precise measurement of the object's temperature, and even tell us which parts of the object are hotter than other parts.
This is especially good for temperatures near those of the Sun, because then the blackbody radiation is in the visible spectrum. (This is not a coincidence; we evolved to see in that spectrum precisely because it is what the Sun produces). For objects much colder than the Sun, the radiation is in the infrared spectrum, so we need special instruments to detect it. (Your body emits infrared blackbody radiation, for example, because it is much colder than the Sun). For objects even hotter than the Sun, the radiation is instead far in the ultraviolet range, and again requires special instruments.
Spectroscopy is even useful, in a somewhat different way, for measuring the "temperature" of molecules or atoms, which are so small that the very concept of "temperature" begins to break down. Really, what we are measuring is their energy, but from thermodynamics we know that if you put enough molecular energy together, you get temperature.