Last week I went to the Apple genius counter to get advice on a problem with Time Machine
Names can be confusing.
Apple sold a device called a Time Capsule which was designed to store backups of Macs. There were 4 different models that looked like this:

Later, Apple introduced a version of the Time Capsule that looked more like a tower about 8" tall.
Time Machine is software on a Mac that is designed to back up the contents of the Mac to another hard drive, which could have been a Time Capsule....or...a regular USB hard drive.
Your post is a bit confusing because it appears that you are calling or have named your Time Capsule Time Machine. Can you please confirm on that?
I was told that the 500 gb external disc was almost full and the problem could probably be resolved if the drive was reformatted.
Apple did sell a Time Capsule version with an internal 500 GB hard drive. This model was discontinued in mid 2009.
So, if you have a Time Capsule (that you are calling a Time Machine) the hard drive is at least 14 years old and likely older, since you probably bought the Time Capsule at a time before it was discontinued.
Frankly, it is amazing that the hard drive lasted as long as it did. Most drives failed after 8-10 years. Don't forget that there is also a power supply inside the Time Capsule, which is as old as the hard drive.
Sure, you could keep formatting the Time Capsule's hard drive when backups fail and then backups will be OK for a few weeks or maybe even a month or more before they fail again.
You won't like hearing this, but no user who values their backups would ever dream of using a 14+ year old hard drive to store them. If you want to continue to use your Time Capsule, the hard drive needs to be replaced.
But....you still have a 14+ year old power supply in the Time Capsule that is way overdue to fail. So, it would not make sense to replace the hard drive in the Time Capsule unless you also replace the power supply.
To do this, you are looking at a repair cost of probably 2-3 times what you originally paid for the Time Capsule. I doubt that you would want to even consider doing this, correct? Even if you would consider this, I think you will have very difficult time trying to find a repair shop to do this, since Apple will not be willing to handle something like this.