Thanks for your reply. I tried to use one certificate template for both virtual smart card logon and TPM endorsement key attestation. That's what wasn't working. When I use separate certificate templates for each purpose everything
works.
It seems like a virtual smart card logon certificate needs the Microsoft Smart Card Key Storage Provider, and a TPM endorsement key attestation certificate needs the Microsoft Platform Crypto Provider.