Ka can be used as possession and preposition for male.
Ko can be used referring to saying something to someone.
Because ka and ko are prepositions and you need to learn where you're supposed to use which one.
Similarly, aapse or tumse and tumhe don't follow a given rule. You need to learn them.
Aapka can mean anyone from these "You, Your & Yours".
Examples:
This is your pen.
یہ قلم آپ کا ہے۔
Yours obediently
آپ کا فرمانبردار۔
Thank you
آپ کا شکریہ
Aapko can mean "to you, you,
Happy birthday to you
آپ کو جنم دن کی مبارک باد
I am missing you.
میں آپ کو یاد کر رہا/رہی ہوں۔
"میں آپ سے یاد کر رہا/رہی ہوں" اس میں حرف جر (preposition) کی غلطی ہے۔
I told you, Sir.
جناب میں نے آپ کو بتایا تھا۔
جناب میں نے آپ سے کہا تھا۔
Both aapko and aapse are used to deliver same meaning if used with different words.
Tumse can mean "to you, from you, you"
I told you, son.
بیٹا میں نے تم کو بتایا تھا۔
بیٹا میں نے تم سے کہا تھا۔
There's no rule here.
Contact with me to learn more about Urdu language.