The IRS matches the last 4 digits of your Social Security Number to the first four letters of your last name, based on what is on record at the Social Security office.
It is possible the SS office thinks your second middle name is the start of your last name.