"R" is a hard sound to pronounce for many, especially children, and so tends to drop out of lots of pet forms.
So
Martha led to Matha, then Mathy, and then
Mattie since the "t" is easier to say than "th".
Then during late medieval times in England
Matty became
Patty and
Patsy. There were a lot of names which had "rhyming" nicknames that changed the first sound back then.
Robert became
Hob and Dob;
Roger became Hodge and Dodge; and
Richard became Hick and
Dick, for instance.
For reasons that are unknown, the popular replacement for "M" at the start of female names was "P". So
Molly, derived from
Mary, became
Polly;
Meg, derived from
Margaret, became
Peg and
Peggy; and
Matty, dervied from
Martha, became
Patty and
Patsy.