How does the environment affect gene expression?
I'll start with a definition. Epigenetics is basically a change in gene expression without any alterations of the genome.
Take a scenario of two identical twins. Their genomes should be identical because the zygote split into two identical parts. However, if they grow up in separate neighborhoods, get raised different ways, go to different schools, etc., and then see each other when they're in their twenties, they're going to look and act very different. The reason they do is not because of their genomes, but because of how they're expressed.
The two specific processes that control gene expression are called methylation and acetylation. Methylation works like this: basically an enzyme adds a molecule, a methyl group, to the nucleotide cytosine, and it causes this cytosine to no longer be able to be coded in the form of proteins. It mutes certain genes.
Methylation mutes genes, so acetylation does the opposite. DNA is wrapped around histones, and the way DNA is wrapped around these proteins determines whether certain gene sequences can be expressed or not. Acetylation adds an acetyl group to the nucleotide lysine, which causes the DNA to detach slightly from the histone, and thus allows the gene to be expressed more easily by RNA polymerase.
Another thing to note: usually methylation is done only once and is more permanent. Such would be the case with most of the genes in all the cells in our body since they all perform specific tasks. Acetylation is constantly happening depending on the environment.
What causes these processes to happen? That's part of the gray area that we don't know the ins and outs of yet. I can't say what precisely causes every acetylation that occurs to affect gene expression, but some factors are definite: nutrition, climate, stress, diet, water quality and minerals, mental stimulation, daily routines and habits, etc..
I hope that's what you were looking for. I learned all of this in AP Biology, and one channel that had a ton of helpful videos was Bozeman Science. I remember watching a video by them on epigenetics, so I might suggest checking that out too.