Here is a long and detailed answer. Sorry, no LaTex!.
Expand the following:
(3 x + (2 y + 1))^2
Treating (1 + 3 x + 2 y)^2 as the binomial ((3 x + 1) + 2 y)^2, expand using FOIL.
((3 x + 1) + 2 y) ((3 x + 1) + 2 y) = (3 x + 1) (3 x + 1) + (3 x + 1) (2 y) + (2 y) (3 x + 1) + (2 y) (2 y) = (3 x + 1)^2 + 2 (3 x + 1) y + 2 (3 x + 1) y + 4 y^2 = (3 x + 1)^2 + 4 (3 x + 1) y + 4 y^2:
2×2 y (3 x + 1) + (3 x + 1)^2 + (2 y)^2
Multiply 3 x + 1 and 3 x + 1 together using FOIL.
(3 x + 1) (3 x + 1) = (3 x) (3 x) + (3 x) (1) + (1) (3 x) + (1) (1):
2×2 y (3 x + 1) + 3×3 x x + 3 x + 3 x + 1 + (2 y)^2
Combine products of like terms.
3 x×3 x = 3×3 x^2:
2×2 y (3 x + 1) + 3×3 x^2 + 3 x + 3 x + 1 + (2 y)^2
2×2 y (3 x + 1) + 9 x^2 + 3 x + 3 x + 1 + (2 y)^2
Distribute exponents over products in (2 y)^2.
Multiply each exponent in 2 y by 2:
2×2 y (3 x + 1) + 9 x^2 + 3 x + 3 x + 1 + 2^2 y^2
2×2 y (3 x + 1) + 9 x^2 + 3 x + 3 x + 1 + 4 y^2
Group like terms in 2 (3 x + 1)×2 y + 9 x^2 + 3 x + 3 x + 1 + 4 y^2.
Grouping like terms, 2 (3 x + 1)×2 y + 9 x^2 + 3 x + 3 x + 1 + 4 y^2 = 4 y^2 + 4 (3 x + 1) y + 9 x^2 + (3 x + 3 x) + 1:
4 y^2 + 4 y (3 x + 1) + 9 x^2 + (3 x + 3 x) + 1
Add like terms in 3 x + 3 x.
3 x + 3 x = 6 x:
4 y^2 + 4 y (3 x + 1) + 9 x^2 + 6 x + 1
Distribute 4 y over 3 x + 1.
4 y (3 x + 1) = 4 y×1 + 4 y×3 x:
4 y^2 + 4 y + 4×3 y x + 9 x^2 + 6 x + 1
4 y^2 + 4 y + 12 y x + 9 x^2 + 6 x + 1