40분 되면 가려 그랬다 = 40분 되면 가려고 그랬다 [= 가려고 했다] = I was thinking of leaving after 40 minutes.
나 같으면 케이크 하나라도 사오겠다 = If it was me, I would have brought a cake or something. (= I'm disappointed that you didn't bring anything)
It is not -아/어 그랬다 but -려(고) 그랬다 in the first sentence.
-려(고) signifies speaker's intention. It is often said like -라구 그랬다 or even -ㄹ라 그랬다 as in the video.
- 본격적으로 운동하려고 학교 체육관에 다녀 = I go to the school gym to work out for real.
There are several ways you can connect a verb with 그랬다.
1 널 도와주려고 그랬어 = I did it to help you = I was trying to help when I did that. (-려고 그랬다 = intention)
2 너무 화가나서 그랬어 = I did it because I was angry. (-아/어서 그랬다 = reason)
3 일찍 오지 그랬어 = You should have come earlier. (-지 그랬어 = criticizing someone for failing to do something)
4 일찍 올걸 그랬어 = (Maybe) I should have come earlier. (-ㄹ걸 그랬다 = regretting not having done something)
5 영화도 보고 산책도 하고 그랬어 = Saw a movie, went for a walk, and what not. (-고 그랬다 = mentioning something very casually)
#3 is special in that it always refers to someone else's action (so it can't take the -다 ending), with a raised, reproachful voice. For example, the second sentence you listed can be said more strongly like this: 케이크 하나라도 사오지 그랬어.