Like courtesy, the word court evolved from the Latin words cum, meaning “together,” and hortus, the derivative of horticulture.
So a court was an enclosed garden where young boys of noble birth learned proper social conduct.
In both the judicial and sporting sense a court is a specified area within which you are expected to practice courtesy while respecting authority.
Legal issues, basketball games, and tennis tournaments all settled on a “court”.