I think that the second and third letters were the two-letter code used by Canadian Pacific to refer to its railway stations. When three-letter coding came in for air transport, it was easy to grab an otherwise little-used letter to prefix to them to produce a new three-letter code.