Do doctoral candidates have to attend courses?
You are obliged to attend courses if you wish to complete the programme of one of the Graduate Schools or if the Committee for Doctoral Examinations have granted admission as doctoral candidate prior to the condition that you complete specific modules in order to broaden your knowledge in the chosen field. And your supervisor may make regular attendance of her/his colloquium for doctoral candidates a prerequisite for her/his continuing commitment. Apart from that you are under no obligation to attend courses.
But you might wish to participate in lectures or courses you deem interesting or helpful for your project and you are free to do so as long as you have the prior consent of the lecturer.