If I were you, I would ask the teacher.

もし私があなたなら、先生に聞くでしょう。

I wish I could swim.

泳げたらいいのに。

「私はあなたではない」「本当は泳げない」のように、現実と違うことを想像して言う形です。過去形を使いますが、過去のことではありません。

ルール○×
if の中は過去形、外は would・couldIf I had time, I would help you.If I have time, I would help you.
be動詞は were(I でも)If I were a bird, I would fly.If I am a bird, I would fly.
I wish + 過去形・couldI wish I could swim.I wish I can swim.

起こりそうな条件は現在形 + will(If it rains, we will stay home.)。現実と違う想像なら過去形 + would・could。この差で区別します。

I wish …(〜だったらいいのに)も同じ仕組みで、後ろは過去形か could です。