The bullet was indeed shattered upon contact with the wall, but the fragments are still embedded within the brick.
According to the script, Batman is recreating the shot so that he can build a 3D template.
This template will then allow him to build a model of the fragments that he can manipulate to recover the fingerprint. The science is hand-waving at best, but it does explain what he's up to from an in-universe perspective. The overall scene is most likely intended to show Batman performing "detective work", which is an aspect of Batman often overlooked on film.
When he first extracts the brick sample at the crime scene:
BATMAN: I need ten minutes with the scene before your men contaminate
RAMIREZ: Us contaminate it? It's because of YOU that these guys are
dead in the first place!
GORDON: Ramirez. (glances at her)
Ramirez stands down and steps away. Batman moves past the bodies to
the wall. Finds an embedded stray bullet. He pulls a sawing device
from his belt - thrusts it into the wall and starts cutting around the
GORDON: That's brick - you're gonna try and take ballistics off a
BATMAN: No. Fingerprints.
Then later, in the temporary Bat-Cave:
The rifle whirs to life - dollying sideways, blasting bullets into a
series of identical brick wall samples.
ALFRED: I'm not sure you made it loud enough, sir.
As the wall samples still smoke, Wayne steps up, carrying the sample
from the crime scene. Comparing its spread to the new samples, he
selects two and carries them to an x-ray scanner. The machine samples
a 3-axis scan. Hi-res 3D images of the bullet fragment arrays come up
on the screen...
INT. APPLIED SCIENCES DIVISION -- DAY
The same image of the bullet fragment on a screen. Fox hits a key and
the computer "reassembles" the bullet according to the identifying
grid on each fragment.
FOX: Here's your original scan.
A bullet fragment array pops up on screen.
FOX: Here it is reverse-engineered.
Fox hits a button and the unmarked bullet fragments are reassembled.
Wayne spins the roughly-shaped bullet puzzle.
WAYNE: And here's a thumb print.
So essentially, he was using an identical bullet to recreate the shot in the same kind of brick material, thus giving him a 3D "mold" of how the bullet fragments would spread out. This in turn gives the software a base model on which it can render the scanned fragments of the original bullet. The end result is a 3D model that you can manipulate & rotate on-screen.
Overall, this process isn't as far-fetched as it seems. 3D laser scanning is quickly becoming a favored tool of law enforcement, and there are numerous companies that work with a police department to scan crime scenes, thus creating a 3D scene which can be manipulated for alternative angles, bullet/splatter trajectory, etc.