TCAS will use the Mode C or Mode S altitude provided by a standard SSR transponder if the intruder aircraft isn't TCAS-equipped. To determine the appropriate maneuver, the system calculates which trajectory will increase the vertical separation at the closest point of approach. TCAS generally favors minimizing disruption by requiring the smallest possible deviation from the current vertical trajectory, but if the intruder is climbing or descending, the system biases the RA based on the threat's current altitude trend, with the expectation that the intruder might level off.
You can read all about the threat resolution logic in section 3.10.8 of ICAO 9863.