Mary Tamm was, at the time, a bit higher profile an actress than had played a companion in... well, pretty much ever (she'd had a lead role in a film, which beat most of her predecessors). She took the part thinking she was going to be co-lead (a bit like the RTD Doctor'n'Rose set up), and decided to leave after one year when that didn't really work out.
Producer Graham Williams hoped right until the last minute that he could persuade her to stay, so she wasn't written out properly (the same thing had happened the previous year, when Leela was written out in a last day rewrite). Then her pregnancy pretty much finished off any chance of a pre-regen cameo even if there'd been the will to do it.
Lalla Ward was cast to take over partly because she and Tom Baker had hit it off while filming Armageddon Factor: Tom was very temperamental by this point and was frequently threatening to quit, so having someone who'd already shown an ability to calm him down on set around was a good idea, as was apparently pointed out by Mary Tamm herself, as she reportedly suggested that Lalla Ward should replace her. And also, the production team had spotted during production of Armageddon Factor that Lalla Ward 'got' Doctor Who, and could cope with the schedules.