Well, that might work in the short term, but isn't really going to play nicely with the rest of the Moodle system.
What happens if the site admin creates a new role 'customteacher' (based on the teacher role) - that will break your block. What happens if there are certain courses where the admin would like users who are 'students' for all other purposes, to see 'link A' in your block? (I have no idea if this is a valid scenario, as 'link A', 'link B' doesn't really give any clue about what the links are for). What about if the admin wants 'editingteacher' users to see 'link A', but doesn't want 'teacher' users to see it?
You really need to be thinking in terms of capabilities that are (by default) assigned to the student / teacher roles, which can then be assigned (or removed) by an admin who is customising the specific roles in use on their site.
Have a read through the Moodle docs for more details: https://docs.moodle.org/dev/Access_API