#"4.032 g"# divided by the molar mass of #"MgO"#, #"40.3044 g/mol"#, gives you moles
#"4.032 g"/"40.3044 g/mol" = "0.10004 moles"#
Then multiply this by #6.02 * 10^23# to get the number of formula units, which would be
#0.10004 cancel("moles") * (6.02* 10^23"f. units")/(1cancel("mole")) = 0.60224 * 10^(23)# #"f. units"#.
Since one formula unit of #"MgO"# contains #2# atoms--one of #"Mg"# and one of #"O"#--multiply this by #2# to get
#0.60224 * 10^(23)cancel("f. units") * "2 atoms"/(1cancel("f. unit")) = 1.204 * 10^(23)# #"atoms"#