Since you have used Cisco terminology in your question, I will assume that you are only talking about Cisco equipment. Also I will assume that you are only interested in L2+L3 devices (like the Cisco Catalyst family of switches), not in the pure L3 devices (like the ISR and ASR routers).
As Zac67 points out, there are some models of Cisco switches with just pure Layer 2 capability and zero Layer 3 capability. All switches in the Catalyst series are, however, capable of some layer 3 functionality, although the software may deliberately disable some layer 3 functionality based on the license etc. and I will confine my answer to these L2+L3 devices.
Rather than distinguish the behaviour based on "this is what a layer 2 switch contains" and "this is what a layer 3 switch contains", a more useful discussion would be based on how layer 2 switching (bridging) is done and how layer 3 switching (routing) is achieved. I will use the word "forwarding" to mean both bridging and routing.
At a high level, there are two approaches: software forwarding and hardware forwarding. As the name suggests, in hardware forwarding the ASIC forwards the packet. In software forwarding the packet reaches the CPU where the software code will examine the various fields of the packet and determine which interface(s) the packet will have to be sent out on. Hardware forwarding is much faster, but software forwarding is more flexible because it is just based on code that some programmer writes.
It is important to note that hardware and software forwarding co-exist. In the ideal case all packets will be forwarded in hardware, but there are situations where the packet cannot be forwarded in hardware and must be forwarded in software. There are many examples of this. For example, there is no Cisco ASIC that supports Appletalk routing, but there are IOS versions that still support Appletalk. If the switch receives an Appletalk packet, and Appletalk is configured, the packet is sent to the software where the Appletalk routing code will route the packet to the correct interface. Another example is an IPv4 packet with one or more Header Options fields present. Another example is when there are so many routes that the hardware table (i.e. ASIC TCAM) is unable to accommodate more routes.
Cisco IOS uses multiple techniques for L3 routing a packet in software: (1) process switching (2) fast switching and (3) CEF switching. These are all different software techniques, with different performance in terms of the maximum number of packets that can be routed per second. Fast-switching #2 is somewhat obsolete. CEF switching uses a software data structure called FIB in order to determine the output interface to which a packet must be sent.
L2 bridging in software has no specific named technique. It's just called "L2 bridging in software".
Coming now to hardware forwarding. ASICs are designed by the vendor keeping in view the requirements of the market segment, one of them being performance and the other requirement being cost. So the components that go into an ASIC are basically the cheapest components that can be put in while at the same time meeting the performance criteria. What I am trying to say is that there is no hard and fast rule that says that L2 bridging must always use a CAM. Yes, for L3 routing, because the requirement is to match on variable length CIDR masks, a TCAM is the most efficient component to use going by today's available technology. However, for doing, say, L2 MAC address lookup (which is a full 48-bit lookup), an ASIC designer may be able to get away by using a cheaper RAM-like component (especially if the entries can be hashed or sorted or arranged in such a way that lookup time can satisfy the performance constraint).
The layer 3 route lookup TCAM in Cisco switches is a hardware representation of the FIB. In other words, the same FIB data structure that is used in software L3 routing technique #3 above is programmed in the hardware TCAM to achieve hardware routing of IPv4 and IPv6 packets.
Note that TCAMs are also used in ASICs for other reasons than L3 routing. One example is to implement security ACLs, and to identify packets for QoS treatment. Cisco 4500 and 3850 switches have TCAMs for both L3 routing as well as for security/QoS.
Final note on "merchant silicon". In recent years, there is a school of thought among major equipment vendors (Cisco, Juniper, Arista...) that there is only so much "secret sauce" that can be put into ASICs, i.e. there isn't much competitive advantage to designing their own custom ASICs for doing L2/L3 forwarding. The competition is now in software innovation, and for this reason the thought process is "why not just source the ASIC from vendors like Broadcom, and focus the innovation efforts in software?" Having said that, at least Cisco has invested several billions of dollars over several decades to build in-house ASICs, and there is a reluctance to just throw it all away.