Social Security taxes are not affected by nor do they affect retirement account amounts.
However, in GENERAL,
Box 1 Wages = Gross Wages minus pretax 401k (but NOT Roth 401k contributions)
Box 2 Federal Tax WH = no formula. Based on tables
Box 3 SS Wages = Gross Wages no subtractions for 401k.
Box 4 SS Tax withheld = should be Exactly 6.2% of Box 3 but not more than $6,324
Box 5 Medicare Wages = Should be the same as Box 3
Box 6 Medicare Tax = Exactly 1.45% of Box 5
There are no other formulas for a W-2/paycheck calculation.
Box 1 Gross wages is reduced by a few other things, notably any pre-tax healthcare (Section 125). Boxes 3 and 5 are similarly affected.
However, Boxes 3,4,5, and 6 do not affect a taxpayer's tax return
AND Boxes 3,4,5 and 6 are supposed to mesh with Forms 941 sent in quarterly.