This might come as a surprise, but it seems that your carpet is among the top places where fleas love to hide. After your dog brings them inside your home, the eggs drop from its fur and end up on your carpet. They are small enough to fall through the fibers and sink deep inside so that even vacuuming might not work in getting them out.
As they develop, they become larvae and adults, and they can wait inside your carpet for a long time before finding a new host. That means they can survive inside your carpet for a while because they are resilient little creatures.