The algorithm was made 2500 years ago, but was it already a problem/puzzle back then? Were scholars already immediately misinterpreting it? I mean, at least the person who wrote it understood it correctly I assume?
Also I'm not sure if I'm understanding everything correctly about the Sanskrit language: does this algorithm define the Sanskrit language, or was this algorithm made to try to describe the Sanskrit language? Usually languages have way too many exceptions to be distilled into simple rules, how was this possible here? It's not a spoken language?
No the scholars did not start immediately misinterpreting it. For example, rishi katyayana who came after rishi panini in his commentarty correctly understands the rule but somehow later scholars started misinterpreting it and it carried to this day until rishi rajpopat went back to the original source and deciphered it correctly (such a funny coincidence his first name is rishi lol)
I am not sure I understand your question. Ashtadhyayi was written by rishi panini to probably codify the already spoken sanskrit language under the umbrella of his 4000 rules. Probably he was frustrated by seeing different people speaking the language in different ways so I guess he and the 10 other rishis predating him that he credits in his book started this exercise.
Also I'm not sure if I'm understanding everything correctly about the Sanskrit language: does this algorithm define the Sanskrit language, or was this algorithm made to try to describe the Sanskrit language? Usually languages have way too many exceptions to be distilled into simple rules, how was this possible here? It's not a spoken language?