We analyzed the polarization-dependent XAFS of Mg K-edge for 10 nm, 20 nm, 30 nm and 50 nm MgB2 films deposited by MBE method on ZnO single crystal. The structure of 30 nm MgB2 film was similar to that for 50 nm one, even the interatomic distances for 30 nm film are slightly shorter than that for 50 nm. This indicates that the quality of 30 nm MgB2 film is enough high as 50 nm and thicker one. On the other hand, the structures of 10 nm and 20 nm MgB2 films were different from 30 nm and 50 nm films. The XAFS of 20 nm MgB2 could be reproduced by the sum of that of 30 nm film and MgO, suggesting that the 20 nm MgB2 film is mixture of hexagonal MgB2 and MgO phase. 10 nm MgB2 has a different structure from 20 nm nor thicker than 30 nm films.