I saw a video where a photo was cropped to be larger in Photoshop. The new additional space was automatically filled with the background color which was white in one photo and black in another. How do you do this? Does it only work with black and white or can it sample any color in the photo? When I tried with a photo with a colored (blue) background it did not work. The additional space was black.
That was likely part two of Zach Arias's Lighting White Seamless video, in which flash is used and post-processing occcurs. What you didn't notice (apparently) is that the color added when "cropping" larger was the background color as in the background color of the brush tool's foreground/background color settings. Photoshop isn't automagically picking out the background color of the image, it's using the color you have selected as the background color in Photoshop. With real black and real white, it works like a charm. With anything else, you can try to select a single color, but you'll notice that that color isn't exactly the same across the entire background, so you'll wind up with an artificial-looking pure color background surrounding your real background.
As dpollitt suggested, use content-aware fill to replace the color you do wind up with.
One way would be to use the content aware tools such as content aware fill. Increase your canvas size, select the new area with a selection tool, and Edit> Fill> Content Aware Fill.
For more info and a video example see: https://helpx.adobe.com/photoshop/how-to/fix-photo-content-aware.html