As mentioned, access to court side usually comes one of 2 ways. A press pass, or a staff pass. I have press credentials (not the same as a press pass) because I worked to get them. I found a few local small newspapers, journals, and web sites, and regularly sent them photos. I also checked through friends to see who might have a contact. Eventually I obtained press credentials from 2 places. This I usually enough to get into smaller events. Heck a big camera, big lenses, and looking the part is usually enough.
A press pass is a pass for a single event (or maybe a season for a team). To get that you have to apply for it with the team or league. Maybe on the spot before the game, but more likely on the web. Bigger events usually want the press entity you represent to request the pass. In other words, you don't apply, whomever gave you the credentials applies. Big events may even charge a fee. I checked on the Super Bowl a few years back and a press pass was $10,000. And of course the number of passes given will also be limited, so you still may not get it.
Persistence and being nice pays off. I applied for the basketball tournament above and was told no. Me and my "employer" were too small time. I showed up to the opening press conference. Looked the part, and asked really nicely. Again, no, all passes available were assigned. An hour later, I was given the pass of a photographer who did not bother to show up.
A staff pass would be even better. I spent 3 seasons working my way into a local pro soccer team as "staff photographer" I received the gig (unpaid, but maybe royalties) and before the next season started they went bankrupt...