I think this may vary slightly between regions, but around the postdoc level I would say. For me personally it was as a postdoc, simply because that's when I decided to write the first grant. For learning how to do it the first time I think it helps a lot if you're able to talk to a professor with grant experience, maybe even look at some of their successful grant texts.
Other than that it's simply a matter of trial and error, and trying to learn as much as possible from failures and trying to get good at reading between the lines of what the particular funding agencies are looking at. It also helps to talk to people who have experience being reviewers for funding agencies, especially if there exists people at your institution that maybe even have time to read through your application and give you direct tips. In addition, some universities/departments have groups/staff that are dedicated at helping with grant proposals, since successful application is a clear benefit to the university/department as a whole as well, so you can try asking around for that.
Hope that answered some of your questions.