I know how plasmids and restriction enzymes work to change the dna of a bacteria cell, but I do not really understand how a bacteriophage works to edit the genome of a cell. Is it related to crispr since its a virus which inserted genetics in bacteria? Also, is it during the lysogenic or lytic stage that the bacteriophage alters the DNA?
As explained in the Wikipedia page that you have linked to, transduction is the name given to a particular phenomenon whereby phage can be used to move bacterial DNA between cells.
Depending upon the phage, some aberrant or infrequent process can result in the packaging of host cell DNA into a phage particle during a lytic cycle. The resulting defective phage particle is still infective however, and when it infects a new host cell it injects the bacterial DNA that it is carrying. This DNA can then recombine with the host DNA.
So, for example, if the second host was a lacZ mutant but the parent host was lacZ⁺, then it would be possible to select lacZ⁺ in the second host.
Transduction was an important tool in E. coli genetics. Phage P1 can be used for general transduction, which means that any piece of DNA can be moved. As I said in my comment: anything that can happen will happen.