The top one is a junction box...as is the bottom one...but the bottom one is to install the camera horizontal usually...
You can go with either style, or go with no junction box and waterproof the connection and shove it into the wall.
You can go with either style, or go with no junction box and waterproof the connection and shove it into the wall.