I know it’s an old question and you’ve probably figured this out by now, at least I hope so, but for anyone else that has a similar question.
The main problem with the above code is the first line
$attachment_id = the_field('bild_startseite_boxen');
the_field() echos the value, when you want to put the value into a variable you must use get_field()
$attachment_id = get_field('bild_startseite_boxen');