BFS visits each node once and examines each edge once. If the graph has nodes and edges, BFS runs in time. Queue operations (push and pop) take each. Marking nodes as visited takes per node. The space complexity is for the queue and visited array.
In the worst case, all nodes could be in the queue at once. For a grid, and is about (or with diagonals), so BFS runs in time.