I've recently seen some of the photos of the victims in the concentration camps. I assume the Nazi guards took these photos? And was there a specific purpose for these photos to be taken?
It depends on the photographs, and the camp where the photos were taken. Many of the photographs we have of camps were taken after liberation, as the Allies took extensive photographs to document what happened. Some of these photos may have been taken as much as a few months after liberation. These photos were made for journalistic purposes, for historical documentation, for commemoration, to prove what had happened and document the horror, and for use in legal proceedings against the upper ranks of the Nazi party.
There are four photos known to have been taken by Jewish prisoners in Auschwitz II Birkenau, which was a death camp as well as a concentration and labor camp. The prisoners who took these photographs were what is called sonderkommando and so the photos are usually referred to as the Sonderkommando Photographs. Sonderkommando were Jewish prisoners forced to get people, mostly Jews, into the gas chambers, then after to strip, sometimes mutilate, and burn the bodies, all on pain of death. They took the photos in August 1944 after large transports from the last remaining Jewish community of Hungary began to slow. They knew this meant that they would be killed soon, and also that it was very likely that very few Jews were left alive in Europe. They also knew that the Allies had landed in Normandy, and that the Soviets were nearing the camp from the East. Because they did not expect to survive until the Red Army arrived they carried out a revolt on October 7, 1944, destroying one of the gas chambers and crematoria, and killing several guards. This revolt had been planned for a long time, and involved contact with resistance groups in different parts of the camp, namely the women imprisoned in Monowitz, and the Polish underground in Auschwitz I. The women in Monowitz helped procure gunpowder to make essentially and IED, and the Polish underground helped provide film and a camera, and smuggled the film out of the camp to be processed and dispersed by the Polish underground outside of the camp. The two plots were enacted mostly by the same people, so taking the photos was in a way a precursor to revolt. These photos were taken under great danger, and are the only photos we have of the actual killing process in Auschwitz. One shows women forced to undress before they are killed, and two others show the sonderkommando burning bodies in outdoor pits which were used when the crematoria overflowed. The sonderkommando did not expect to survive, or save anyone through revolt, rather it was to choose how they died, and take as many Nazis as they could with them. A few survived and said that it was "so they could die like human beings," The photos were taken so that when they were all killed, either in the revolt or through a selection, that evidence of what was done at Auschwitz would survive.
The rest of the photographs of camps were mostly taken by perpetrators. The einsatzgruppen and other auxiliary killing squads were so known for photographing their victims and the graves, that they actually had to be ordered to stop sending photos home to Germany. Some photos in concentration camps like Dachau were taken for propaganda purposes, while others, mostly of Auschwitz (a death camp, as well as a labor/concentration camp) and the concentration camps in Germany were taken to document the building process. Other photos such as those in the Auschwitz Album, a collection of German made photos of Auschwitz, mostly of people about to be killed, were taken for some kind of pride, posterity, or pleasure. Sometimes it was to show your buddies, or your wife or girlfriend, that you were doing "important work for the Reich." Other times they were taken to prove stereotypes, to show Jews as dirty, or other things which fit into the Nazi worldview. It was also a kind of bragging, not only are you as a guard at the heart of the Nazi system but you are doing this most important work of murdering Jews.
Because of the extreme differences in motivation, it's really important to know who took the photos when looking at Holocaust images. Much of the time you will find you're looking at an image that wasn't ever meant to let you feel empathy for the victims because it was taken by their murderers. You're essentially looking through the eye of the murderer, and that's really important to know because it fundamentally changes how you view the image.