Why OSPF uses flooding instead of using multicast?
Those are two very different concepts. OSPF on a broadcast network uses multicast to exchange routes. It floods by telling ever other OSPF router to which it is connected in the same area about all the routes it knows. That is using multicast and flooding with.
We know that flooding is only possible in layer2 switch.
That is a completely different thing than OSPF flooding. The word is the same, but it is a very different meaning.
Suppose we have one router in OSPF uses multicast address 225.0.0.9.
That would not work. That multicast group is used by RIPv2, not OSPF.
If router sends a message, every router get the message belongs to same group using class D address 225.0.0.9.
No, because an OSPF router does not listen to that multicast group, and the multicast packets will be dropped at the interface.
If I using multicast address so why flooding is necessary because by multicasting everyone get message?
You are confusing the flooding term. An OSPF router can have neighbors on multiple interfaces. The OSPF flooding term means it tell all its connected OSPF neighbors in the same area about the routes it has. OSPF on a broadcast network does use multicast, but it is a link-local multicast that cannot be sent to a different network. The OSPF router needs to send routes to all the OSPF routers in its area that are connected to all its interfaces that are participating in the OSPF process. Some of the interfaces may be using a broadcast medium, and some may be using a non-broadcast medium where multicast is not supported.
If I use unicast instead of multicast what's problem will be happen ?
You need to understand the differences between OSPF on a broadcast medium (elects DR and BDR and uses multicast) and on a non-broadcast medium (must have neighbor addresses configured and exchange routes with each neighbor individually).