You can buy tickets farther in advance. If you go here -
https://disneyland.disney.go.com/admission/tickets/
Scroll down to the fine print and it will tell you when the tickets expire. Right now it says
One-day tickets that are purchased through
Disneyland.com or the
Disneyland app today are valid now through December 30, 2024.
Multi-day tickets purchased through
Disneyland.com or the Disneyland app today must be used within 13 days of first use or by January 12, 2025, whichever occurs first.
You can also purchase multi-day tickets from sites like Getaway today for a discount, usually. But again, always double check expiration.
RESERVATIONS, on the other hand, can't be made until a few months before. So if you're worried there may not be reservations available for dates, then you'd probably want to wait to buy tickets. Though you already reserved a hotel so...that's up to you, I guess.
I've always purchased our tickets way before we can make reservations. Though we don't travel on super popular dates like holidays so I've never been concerned about not getting a reservation.