How do the military air defense radars and aircraft radars detect the type of an aircraft and enemy or friendly information?
This depends on the type of radar system and its intended application. You can find a nice bit of history on it here. The early radars could not tell the difference between aircraft types, any kind of movement was coordinated beforehand on the friendly side and anything that was not pre-arranged was considered foe. The early Doppler systems that resided on the DEW Line could be trigger by as little as a dense flock of birds. The early radar data from the DEW Line was processed on the SAGE system a very early (very primitive) system for coordinating a great deal of weather, radar, and flight information.
After WWII and through out the cold war era newer tech was built to solve the issue of coordination. The modern Identification Friend Or Foe system that is now in use provides at least some way to pick apart radar targets.
With the advent of modern computer processing and the ability to analyze radar returns beyond staring at a scope it is possible to determine (with great certainty) the make of an aircraft by its radar signature (and in some cases thermal signature). Also known as Radar Cross Section. Everything (even stealth planes) have a radar cross section and once a cross section has been identified it could be used again to check against future pings.
One could go as far as to say there is some historical precedent around this. The general idea of "if it comes from over there is one of them, if it comes from over hear its one of us" is very much how radar worked for a long time and the identification of the actual plane was less important than identifying that it was there. If an unidentified target entered a radar area and did not identify its self, over the radio, with some kind of transponder and or at a preordained time it was intercepted. Not until visual identification was made was it not longer considered a threat.
Here in the states by 2020 the civilian world will be sending speed and position data via ADS-B OUT to supplement (and potentially replace) radar returns.
Classic radar works by reflection radiowaves of objects. The time it takes for the radiowave to come back to the radar, determines the distance. Depending on how many of the transmitted radiowaves are being reflected back, you can determine the approximate size of the object.
If an object is moving, the distance will vary, and you can calculate the speed. You could make an educated guess as to what type of aircraft is detected by radar, based on size and speed. That is how they did it in the early days of radar.
Nowadays, detecting the type of aircraft, is done with transponders. The aircraft itself will broadcast its type and position. Traditional radar is only used as backup on most airfields if a transponder fails.
Military uses ofcourse are different. Norad will monitor the skies for instance for any objects that cannot be identified by tranponder signals. And stealth planes will not show up on radar anyway, and will ofcourse need to identify themselves using a secure transponder.
Radar can only detect position and speed of objects. The amount of reflected energy may be used to estimate the size of the object, but other factors also have an impact on the amplitude of the radar echo: shape, roughness, paint, apparent angle.
Size and speed give a clue to the class of aircraft. Friendly aircraft are known, or respond, or announce themselves. Silent unknown aircraft are potentially hostile.