A figure is divided into 12 equal squares. 4 of the squares are shaded.

When some shaded and unshaded squares are added to the figure, the fraction of the figure that is shaded becomes 3/8. How many squares are there in the final figure?

Don't know what your "figure" looks like, but it seems there are 4 shaded squares and 8 unshaded squares

Now the question becomes unclear.
Are the number of shaded squares and unshaded squares , that are added, equal?
if so, let the number of squares of each be x
(4+x) / (8+x) = 3/8
32+8x = 24+3x
x would be a negative, so clearly that is the wrong interpretation.

perhaps you meant:
(4+x)/(8+x) = 3/5
20 + 5x = 24 + 3x
x = 2

that makes sense, so the final figure would contain 4+2 and 8+2
or 16 squares.