The highest level public offices should always be either directly elected, or appointed by an elected person for only the duration of their office. This way voters can get rid of them if necessary. Otherwise they become an unelected deep state.
Other levels of public office should be strictly by competence. Meaning by trials open for all citizens.