A spokesperson for the White House was not immediately available for comment when contacted by CNBC.

"Both times he wanted to know if there was a difference between HIV and HPV, so I was able to explain that those are rarely confused with each other."

Gates recounted meeting Trump twice after he was elected president: in December 2016 and in March 2017. He expressed mild incredulity at Trump's questions about two well-known viruses.

Footage of the Microsoft founder, aired on MSNBC late Thursday , shows the billionaire philanthropist responding to questions at the Bill & Melinda Gates Foundation meeting and describing his first exchanges with the president.

Bill Gates told an audience recently that President Donald Trump twice asked him the difference between HPV and HIV.

The questions apparently followed a conversation about the effects of vaccines, a topic that remains controversial in the U.S., where some people and lawmakers believe common immunization vaccinations are harmful.

"In both of those two meetings, he asked me if vaccines weren't a bad thing because he was considering a commission to look into ill effects of vaccines and somebody — I think it was Robert Kennedy Jr. — was advising him that vaccines were causing bad things. And I said no, that's a dead end, that would be a bad thing, don't do that," Gates recalled.

HPV stands for human papillomavirus, which the U.S. National Institutes of Health defines as "a group of related viruses" transmitted sexually that can cause warts and, for some types of the virus, cancer. HIV stands for human immunodeficiency virus, a sexually transmitted disease that breaks down the immune system and can lead to AIDS. "Not everyone with HIV develops AIDS," the NIH says.

"There was a thing during the election where he and I were at the same place and I avoided him," Gates also said, garnering laughter from the audience.

The Bill & Melinda Gates Foundation is said to be the wealthiest charity foundation in the U.S. with more than $42 billion in assets.

The Trump administration proposed significant cuts to programs helping to treat and prevent HIV/AIDs in its 2018 and 2019 budgets. The reductions in the 2019 budget included slashing $40 million from the Centers for Disease Control and Prevention's HIV/AIDS prevention programs as well as $26 million from a federal housing plan for people with HIV.

Outside the U.S., the budget proposed a 20 percent cut of more than $1 billion in global HIV funding for 2019. Neither of the original budget proposals was passed by Congress.