How do I make a controllable camera that can orbit an AI?

To attach use AttachActorToActor.

You attach the whole CameraPawn to the AI, not just the camera.

To rotate the camera check “usePawnControllerRotation” inside the SpringArm.

to add actual input, your pawn has to POSSESS player controller (GetPlayerController → Possess)

Check out https://youtu.be/CYiHNbAIp4s?si=XVvEOYMts_ILOUxm to add inputs