The King was seen at a church service in Sandringham on Sunday, where he waved to crowds and walked for about 10 minutes.
He had a prostate procedure at a private London hospital more than a week ago.
At the time, the Palace said the treatment was for a "benign" condition.
"It was during this intervention that a separate issue of concern was noted and subsequently diagnosed as a form of cancer," it said on Monday.
The King chose to go public about his cancer treatment, the Palace said, as he had been a patron of a number of cancer-related charities when he was Prince of Wales.
"In this capacity, His Majesty has often spoken publicly in support of cancer patients, their loved ones and the wonderful health professionals who help care for them."
He had also gone public about his prostate treatment, with the aim of encouraging more men to get prostate checks.
He was said to have been delighted to have raised awareness about the issue, with the NHS website reporting a surge in issues about prostate conditions.
The Royal Society of Medicine thanked the King for highlighting "how cancer is indiscriminate" and urged members of the public eligible for cancer screenings to make an appointment.
"Please don't be shy - the more information we have the better to help, hopefully rule out cancer, or, if not, put you on the most suitable treatment pathway," said Dr Jay Verma, president of the general practice with primary healthcare section of the Royal Society of Medicine
One in two people in the UK develop some kind of cancer during their lifetime.
There are more than 200 types of cancer - the most common ones in the UK are breast, lung, prostate and bowel, according to the NHS website.
For many types of cancer, the chance of getting it increases with age. UK figures suggest, on average each year, more than a third (36%) of new cancer cases were in people aged 75 and over.
Prime Minister Rishi Sunak wished the King a "full and speedy recovery", as did Labour leader Sir Keir Starmer and Commons Speaker Sir Lindsay Hoyle.
In a post on X, he later said: "Navigating a cancer diagnosis, treatment, and survivorship takes hope and absolute courage. Jill and I join the people of the United Kingdom in praying that His Majesty experiences a swift and full recovery."
Mr Biden's son, Beau, died of brain cancer aged 46, and his long-time friend, Republican Senator John McCain, also died of cancer in 2018.
Charles acceded to the throne on the death of his mother Queen Elizabeth II in September 2022, and his coronation took place the following May.
The King and Queen are scheduled to visit Canada in May, and Australia, New Zealand and Samoa for the Commonwealth Heads of Government Meeting in October.
The Palace has yet to confirm whether the tours will go ahead, with no date suggested for the King's return to full public duties.
You can get all the latest royal stories and analysis straight to your inbox every week with our Royal Watch newsletter - sign up here