The Japanese attack on Pearl Harbor was mainly by air, but there were several submarines in the effort as well. They were mostly a failure. The attack was designed by Admiral Isoroku Yamamoto, and his goal was to minimize damage to the Japanese Imperial Navy. He believed that if Japan attacked by air, they would be able to cause the most damage possible to the fleet at Pearl Harbor. He hoped the attack would be more difficult to detect, and he was proved right.
Was Yamamoto attempting to invade the US? No. The attack at Pearl Harbor wasn’t about bringing the war onto American soil so much as it was about hurting the US so badly that they would be scared and forced to surrender. Although Yamamoto got many things right about Pearl Harbor, he was very wrong to think America would surrender.