Update 3 and corrected answer
There's an error in the linked solution set (see update 2 below), but it can be easily corrected with @Yuval Filmus's suggestion in the question's comment, which further allows us to rule out one of the possibilities mentioned in the solution set.
Let $s$ be the root of the first BFS and let $u$ be the final vertex discovered. Also, let $d(a,b)$ be a diameter. Clearly, $a$, $b$, and $u$ must all be leaves, since otherwise $d(a,b)$ wouldn't be a diameter, and $u$ wouldn't be discovered last. Let $t$ be the lowest common ancestor of $a$ and $b$.
We claim that $t$ must be an ancestor of $u$. Suppose that it were not, then let $r$ be lowest common ancestor of $u$ and $t$. Then since $u$ was discovered last, we have $d(u,s) \geq d(u,r) \geq d(a,r) > d(a,t)$ since $r \neq t$, and thus $d(u,b) = d(u,r) + d(r,t) + d(t,b) > d(a,t) + d(t,b) = d(a,b)$, contradicting the latter being a diameter.
Hence $t$ is an ancestor of $u$, and then $d(t,u) \geq d(t,a)$, since otherwise $u$ would not have been discovered last. Also, $d(t,u) \leq d(t,a)$, since otherwise $d(a,b)$ would not have been a diameter. Hence $d(u,b) = d(a,b)$ and thus $u$ is the endpoint of some diameter, and thus the second BFS works.
Update 2
Note that the linked solution set contains an error:
If the paths $p_1$ from $s$ to $u$ and $p_2$ from $a$ to $b$ do not share edges, then the path from $t$ to $u$ includes $s$.
Consider the following counterexample: suppose $s$ is the root of the first BFS tree, and $t$ is the lowest common ancestor of leaves $a$, $u$, and $b$. No edges are shared; only the vertex $t$ is shared. Let $d(a,t) = d(b,t) = d(u,t) = 2$, and let $d(s,t)=1$. Finally, suppose $u$ is discovered last in the BFS. Then $d(a,b)$ is a diameter, $t$ is the first node discovered on that path, and the path from $t$ to $u$ does not include $s$.
To fix this, it's probably necessary to change "do not share edges" to "do not share vertices, as suggested by @Yuval Filmus.
Update
As @j_random_hacker points out in the comments, Lemma 1 below is not sufficient to show that $u$ is an endpoint of some diameter. Hence, the below proof is incomplete.
Original incorrect answer
Suppose we have $d(a, b)$ being a diameter, but we don't know which vertices $a$ and $b$ are, so we start a BFS from some vertex $s$.
If $s = a$, then the first BFS would yield either $b$ or some node $b'$ equally distant from $a$, and the second would either go back to $a$ or to some equally distant node $a'$, and the scheme obviously works. Similarly, if $s = b$, then two BFS would work for the same reason.
Otherwise, we have $s \neq a, b$.
Lemma 0: Both $a$ and $b$ are leaf nodes in the tree rooted at $s$.
Proof 0: If they weren't leaf nodes, we could increase $d(a,b)$ by extending the endpoints to leaf nodes, contradicting $d(a, b)$ being a diameter.
Lemma 1: At least one of $d(s,a)$ and $d(s, b)$ is the largest possible value of $d(s,u)$ for all $u$.
Proof 1: Suppose we have a $u$ that violates the lemma. $u$ cannot be a descendent of $a$ or $b$ since they are leaves from Lemma 0, and $u$ cannot be an ancestor, since that would make it closer to $s$, and it would no longer be able to violate the lemma. Let $t$ be the lowest common ancestor of $a$ and $b$. If $t = s$, then both $d(a, u)$ and $d(b, u)$ would be greater than $d(a, b)$, a contradiction. Otherwise, $t \neq s$ and either $u$ is a descendant of $t$, or not.
If $u$ is a descendant of $t$, then since $d(s,u)$ is greater than both $d(s, a)$ and $d(s, b)$, we have $d(t,u)$ is greater than both $d(t, a)$ and $d(t, b)$ and thus $d(a, u)$ and $d(b,u)$ are both greater than $d(a,b)$, a contradiction since $d(a,b)$ is a diameter.
If $u$ is not a descendant of $t$, then let $w$ be the unique ancestor of $u$ such that $d(s,t) = d(s,w)$. We know $w$ exists because $d(s,t) < d(s,u)$. Then, we have $d(t, b) < d(w,u) < d(t,w) + d(w,u) = d(t,u)$ and thus $d(a, u) = d(a, t) + d(t, u) > d(a, t) + d(t, b) = d(a, b)$, again contradicting $d(a, b)$ being a diameter.
Main result: Starting from any root $s$ and performing a BFS will result in some $a$ being discovered last. Using that $a$ as the root of a second $BFS$ will result in $b$ being discovered last, with $d(a,b)$ guaranteed to be a diameter.
proof: From lemma 1, the first BFS will find an $a$ that is furthest from $s$, which is guaranteed to be one of the endpoints of a diameter. The second BFS will find that diameter, since in a tree there's exactly one simple path between any two nodes.