They manufacture their own chips, a particularly difficult task with cutting edge technology. Also note that they also make general purpose DRAM, which is a lot more expensive per GB, and graphics DRAM, which is even more expensive. Those really help to pay back the huge investments of constantly upgrading fabs to stay competitive. The margins on Flash are thin, but they are able to more than make up for it with very high production volume.