Many times people communicate boundaries in subtle ways. Often they also expect that certain boundaries commonly accepted by the society or general group you both belong to will be respected without any need for even subtle communication.
Having to repeatedly clarify my boundaries to each and every or even just one person would take a lot of my time and energy and it would definitely gnaw on my nerves.
There already was some communication about boundaries, as you are certain that they value their boundaries.
What you now need is empathy. And that seems to be a little lacking on your part, to be honest. I will try and go through the three examples you gave in your comment:
For example, I might sit in and listen to his meeting with his other students and ask some questions.
This is not only about your professor establishing their own boundaries, it is also about the other student's boundaries and potentially your supervisor protecting those. There is an advisor-student relationship and if it is good there is quite a bit of trust and value in it.
Did the students agree that you can participate? One-on-one time with an advisor is a precious good that many cannot afford to pass on. Did your supervisor agree that you listen? He might need to discuss issues with the other students that are none of your concern. Even if they agreed that you stay and listen, they might not have the time to explain and discuss everything with you. It is them working on their project. Meetings can be lengthy and hard and if you want to avoid that you need to be effective. An outsider actively joining is often disruptive to that effort.
Or I tried to invite him to lunch and have some casual discussion with him.
As every person, they have a right to not want to go to lunch with you. As your supervisor and someone who is going to grade you somehow in the future, with all the friendliness that can be involved it is more common in a group setting. Going for lunch alone with one of your students can lead to talking behind their back for them. And you won't profit from that either. In life there is a general guideline that in a friendship between people in different levels of the same hierarchy, the higher up should make the next step. They will know how far they can acceptably go and how far they want to take it. Or they might decide to only do this after the supervisor-student relationship as such has ended.
From time to time I will also try to share my snacks with him as I do to all of my friends.
As long as you offer them to everybody else in the room/group/lab as well?
Giving out snacks or treats to a specific person can look like bribery. Not everybody would think so, but the few who do are enough to start gossip. But I would rather again offer to share in a group setting. Definitely not walk up to them specifically unless you are also walking up to everyone else who is around.