Swap rate vs Z spread

As per my understanding, both help measure the credit and liquidity risk in a swap transaction over a T-bill. While swap rate is calculated using the YTM, the Z spread is calculated using spot rates. I am trying to understand why we need them both if both help quantify the same thing? Also, spot rates can be derived from YTM (and vice versa…), how do we end up with different values of Z spread and swap rate? Shouldn’t they be the same?