Duden gives the word Kompetenz two meanings. The first is Sachverstand; Fähigkeiten, expert knowledge and ability. The second is Zuständigkeit, responsibility for an area, and Duden marks it as chiefly legal usage. The adjective inkompetent works the same way. Duden’s example for the legal sense is ein für diese Fälle inkompetentes Gericht, a court that is not competent for these cases. That court may be excellent. The cases are simply not its cases.
Two studies of the word’s history agree that it entered German through legal language, and that the meaning “ability” became common late. They disagree on the dates. Anton Hügli dates the noun meaning jurisdiction to around 1700, and says the meaning ability does not appear before the middle of the twentieth century. Frank Bünning and Hanno Hortsch date both meanings to the nineteenth century.