I learned them through memorization, obviously. I'm still having trouble with distinguishing 「シ」、「ン」、「ツ」、and 「ソ」, but it can't be helped.
I'd recommend practicing by writing them over and over again, in the proper stroke order (that's how I memorized them, anyway). That way you can tell katakana shi/tsu and n/so apart. Remember that katakana shi has the curvy line going up 「シ」, and tsu has it going down 「ツ」. Katakana n has it going up 「ン」, and so has it going down 「ソ」.